【发布时间】:2017-10-11 20:43:19
【问题描述】:
我是 iOS 新手。我正在练习objective-c并制作了我的自定义UITableViewCell。它有一些高度而不是它的默认高度,即高度是 120。但是当我运行程序时,单元格显示在它们的默认高度上。我只写了一些代码如下,我正在使用 xib 来设计自定义单元格。如果需要,我可以分享屏幕截图。谢谢
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CustomCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
cell = [topLevelObjects objectAtIndex:0];
}
return cell;
}
编辑 在我的一个项目中,我没有实现 heightforrowatindexpath 方法。为什么我必须在另一个项目中实施。有必要吗??请指导。
【问题讨论】:
标签: objective-c xib