在 ImageView中减少图像大小有问题. 在CollectionViewCell中有ImageView的约束:两个水平和两个垂直空间. 第一个屏幕是iOS7,第二个屏幕是iOS8. ImageURL它是通过URL加载图像的自定义类,它工作正常
在CollectionViewCell中有ImageView的约束:两个水平和两个垂直空间.
第一个屏幕是iOS7,第二个屏幕是iOS8.
ImageURL它是通过URL加载图像的自定义类,它工作正常,也设置了像这样的图像
_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;
}
//==============================================================================
在Xcode6中,“界面”构建器不会显示Cell的内容视图.
CollectionViewCell在iOS7中具有内容视图,其框架设置为默认值(0,0,50,50).
您需要在CollectionViewCell子类中添加此代码,因此contentView将自行调整大小
- (void)awakeFromNib
{
[super awakeFromNib];
self.contentView.frame = self.bounds;
self.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
