Problem with autodetect UIImageView in UICollectionViewCell on iOS7 but on iOS8 this is ok
Having problems shrinking the image size in the ImageView. CollectionViewCell has an ImageView with two horizontal and two vertical spaces.
The first screen is iOS7 and the second is iOS8.
ImageURL is a custom class to load image from url, it works fine, also set image like
_clothesImageView.image = [UIImage imageNamed:@"imageName.png"];
- (void)configCellWithClothesModel:(ClothesModel *)clothesModel
{
[_clothesImageView setImageURL:[NSURL URLWithString:clothesModel.imageURL]];
}
ClothesModel:
- (instancetype)initWithDict:(NSDictionary *)dict
{
self = [super init];
if (self)
{
_isShop = @(YES);
self.title = [self checkNullAndNill:dict[kTitle]];
self.info = [self checkNullAndNill:dict[kDescription_Short]];
self.artNumber = [self checkNullAndNill:dict[kArtNumber]];
self.afLink = [self checkNullAndNill:dict[kDeeplink1]];
self.imageURL = [self checkNullAndNill:dict[kImg_url]];
_isCart = @(NO);
}
return self;
}
//==============================================================================
- (id)checkNullAndNill:(id)object
{
if (object == nil)
return @"";
else if (object == [NSNull null])
return @"";
else
return object;
}
//==============================================================================
- (UICollectionViewCell *)configCellWithType:(NSString *)type collectionView:(UICollectionView *)collectionView indexPath:(NSIndexPath *)indexPath
{
ClothesCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:[type isEqualToString:@"Outfits"] ? @"CellOutfits" : @"Cell" forIndexPath:indexPath];
[cell configCellWithClothesModel:self];
return cell;
}
//==============================================================================
source to share
In Xcode6, the interface builder does not render the Cell content view. CollectionViewCell has a content view in iOS7 and its frame is set to default values (0,0,50,50).
You have to add this code to subclass of CollectionViewCell so the contentView will resize
- (void)awakeFromNib
{
[super awakeFromNib];
self.contentView.frame = self.bounds;
self.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
source to share
It really depends on the autorun settings. UIImageView
usually set their sizes based on their own content size, which is set to the size of the image they are hosting.
If a collection view cell does not have enough restrictions, what you see may depend on the implementation of the autorun mechanism on different iOS.
Also check the image content mode as indicated in the comments.
source to share