大佬教程收集整理的这篇文章主要介绍了ios TableView不同的单元格高度,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
- (CGFloat)tableView:(UITableView *)tableView heightForRowATindexPath:(NSIndexPath *)indexPath
如果我有一个单元格标识符的静态值,那么单元格内图像的高度不能动态变化.
那么我是否需要为每个细胞设置不同的细胞标识符值?还有其他方法吗?
我不能使用除Tableview之外的其他视图,因为我需要根据用户交互动态显示一些单元格.
谢谢.
-(CGFloat)tableView:(UITableView *)tableView heightForRowATindexPath:(NSIndexPath *)indexPath { UIImage *image = dataModel[indexPath.row]; return image.size.height + 16.0; //16 is for padding }
如果您对单元格进行子类化,则可以在-layoutsubviews中调整imageView框架(超级之后):
- (void)setupImageView { UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectZero]; imageView.contentMode = UIViewContentModeScaleAspectFit; imageView.clipsToBounds = YES; self.contentImageView = imageView; [self.contentView addSubview:imageView]; } - (void)layoutSubviews { [super layoutSubviews]; CGRect bounds = self.contentView.bounds; float margin = 8.0; CGRect textViewFrame = CGRectZero; textViewFrame = CGRectMake(margin,roundf(margin * 2.0),bounds.size.width - (margin * 2.0),roundf(bounds.size.height - (margin * 4.0))); self.contentImageView.frame = textViewFrame; }
以上是大佬教程为你收集整理的ios TableView不同的单元格高度全部内容,希望文章能够帮你解决ios TableView不同的单元格高度所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。