heightForRowAtIndexPath
全部标签 我有一个自定义的UITableViewCell。我想访问单元格属性,即UILabel等。我尝试插入以下代码:-(CGFloat)tableView:(UITableView*)tableViewheightForRowAtIndexPath:(NSIndexPath*)indexPath{CategorieCell*customCell=(CategorieCell*)[tableViewcellForRowAtIndexPath:indexPath];return...}当我运行该应用程序时,它崩溃了,但没有提供错误详细信息。问题出在我正在创建的新customCell上。还有其他方法
我有一个表格View,其中包含动态调整大小的单元格。这在iOS8中运行良好,但在iOS7中不受支持。我需要实现tableView:heightForRowAtIndexPath否则应用程序将在iOS7中崩溃。如果我这样做,我将不得不计算单元格的高度.问题是,如果我实现这个方法,iOS8会注意它并且不再执行其动态大小的单元格魔术。有没有办法只为iOS7客户端实现此方法? 最佳答案 我以前用过类似的东西:-(CGFloat)tableView:(UITableView*)tableViewheightForRowAtIndexPath:
我在我的应用程序中创建了自定义单元格。我想获取HeightForRowAtIndexPath中的每个单元格。请告诉我如何在此方法中获取自定义单元格。我已经尝试过这段代码,但是导致无限循环并最终使应用程序崩溃。HomeCell*cell=(HomeCell*)[tableViewcellForRowAtIndexPath:indexPath];编辑:我已经试过了,但它让我的单元格高度为零。-(CGFloat)tableView:(UITableView*)tableViewheightForRowAtIndexPath:(NSIndexPath*)indexPath{staticNSSt
如题,这两种方法有什么区别?我发现如果我用tableView:heightForRowAtIndexPath:设置它的高度,然后我想得到高度的值,我会得到一个正确的值:CGFloatheight=cell.frame.size.height;但是这是一个错误的值,结果是44:CGFloatheight=tableview.rowHeight;但如果我以另一种方式设置它--setRowHeight:,我可以通过两种方式获得正确的值。那么它们之间有什么不同呢? 最佳答案 rowHeight是UITableView的属性,用于在委托(de
我这样设置我的单元格:所以,几个开关,定义单元格,因为数据不在对象列表中,而是一组应该以不同方式显示在tableView中的信息。-(UITableViewCell*)value1CellForTableView:(UITableView*)tableView{staticNSString*CellIdentifierValue1=@"Value1Cell";UITableViewCell*cell=[tableViewdequeueReusableCellWithIdentifier:CellIdentifierValue1];if(cell==nil){cell=[[UITable
这个问题在这里已经有了答案:DifferencebetweenUITableViewDelegateandUITableViewDatasource(4个答案)关闭6年前。我发现这个方法是一个UITableView委托(delegate)方法:-(CGFloat)tableView:(UITableView*)tableViewheightForRowAtIndexPath:(NSIndexPath*)indexPath{return20;}我真的很困惑,为什么它不是数据源方法?
我试图在单元格的setProperty中访问TableViewCell的高度。我通过xib创建单元格,然后根据heightForRowAtIndexPath中返回的值更改高度-(CGFloat)tableView:(UITableView*)tableViewheightForRowAtIndexPath:(NSIndexPath*)indexPath{return200;}-(UITableViewCell*)tableView:(UITableView*)tableViewcellForRowAtIndexPath:(NSIndexPath*)indexPath{RightGuid
我正在构建一个具有可变高度自定义表格单元格的UITableView,它们的高度由包含的多行UILabel的大小决定。我已经连接了tableView:heightForRowAtIndexPath:委托(delegate)方法,并使用sizeWithFont:constrainedToSize:正确计算了最终高度。我遇到了一个奇怪的问题:当调用数据源方法tableView:cellForRowAtIndexPath:时,正确的每行高度已经如上所述确定,但是单元格与该高度不匹配。相反,单元格的frame.size.height属性是表格View的默认单元格高度(86像素,正如我在Inter
我在大型项目中为我的新UITableViewCells使用自动布局。我有一个自动计算每行高度的TableView,我没有使用委托(delegate)函数heightForRowAtIndexPath。我已经声明了估计的行高:tableView.estimatedRowHeight=44.0tableView.rowHeight=UITableViewAutomaticDimension我的问题是:在另一个TableViewController上有很多UITableViewCells,我需要以编程方式在heightForRowAtIndexPath中声明单元格的高度。我知道最好将所有单元
我有一张包含静态单元格的表格。对于一个单元格,我想根据标签的高度(在该单元格内)更改其高度,同时保持所有其他单元格的高度不变。如何获得当前单元格的高度?或者也许有更好的方法?-(CGFloat)tableView:(UITableView*)tableViewheightForRowAtIndexPath:(NSIndexPath*)indexPath{if([indexPathsection]==2){returnself.myLabel.frame.origin.y*2+self.myLabel.frame.size.height;}else{return...;//whatsho