Ios 获取UITableViewCell的高度
我想将我的Ios 获取UITableViewCell的高度,ios,objective-c,uitableview,height,Ios,Objective C,Uitableview,Height,我想将我的UITableViewCell的高度设置为我在故事板中指定的高度 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath{ UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; return cell.frame.size.height; } 使用此代
UITableViewCell
的高度设置为我在故事板中指定的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
return cell.frame.size.height;
}
使用此代码,应用程序崩溃。您必须明确设置高度。在
–tableView:heightforrowatinexpath:
中调用-cellforrowatinexpath:
会在这两个方法之间创建一个无限循环。这是表视图中常见的第一个错误
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath{
return 64; // some value
}
仅在有关IDE本身的问题上使用标记。谢谢