iOS7上的UICollectionViewCell中的UIImageView自动布局问题,但在iOS8上也没关系

iOS7上的UICollectionViewCell中的UIImageView自动布局问题,但在iOS8上也没关系,第1张

概述在 ImageView中减少图像大小有问题. 在CollectionViewCell中有ImageView的约束:两个水平和两个垂直空间. 第一个屏幕是iOS7,第二个屏幕是iOS8. ImageURL它是通过URL加载图像的自定义类,它工作正常,也设置了像这样的图像 _clothesImageView.image = [UIImage imageNamed:@"imageName.png"]; 在 ImageVIEw中减少图像大小有问题.
在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,50,50).
您需要在CollectionVIEwCell子类中添加此代码,因此contentVIEw将自行调整大小

- (voID)awakeFromNib{   [super awakeFromNib];   self.contentVIEw.frame = self.bounds;   self.contentVIEw.autoresizingMask = UIVIEwautoresizingFlexibleWIDth | UIVIEwautoresizingFlexibleHeight;}
总结

以上是内存溢出为你收集整理的iOS7上的UICollectionViewCell中的UIImageView自动布局问题,但在iOS8上也没关系全部内容,希望文章能够帮你解决iOS7上的UICollectionViewCell中的UIImageView自动布局问题,但在iOS8上也没关系所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1012441.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存