【发布时间】:2013-04-15 16:06:32
【问题描述】:
我正在尝试使用两种不同格式的 UITableViewCells,具体取决于它是 iPad 还是 iPhone。两个单元格显示相同的信息,但 iPad 单元格的高度是一半,宽度是两倍。所以信息显示在一行而不是两行。
在我的cellforRowatIndexPath,
我正在输入代码:
HistoryCell *cell;
if (self.isiPad) {
cell = [self.tableView dequeueReusableCellWithIdentifier:@"historyiPadCellType" forIndexPath:indexPath];
}
else{
cell = [self.tableView dequeueReusableCellWithIdentifier:@"historyCellType" forIndexPath:indexPath];
}
但是,如果我在同一个 XIB 中有 2 个 UItableViewCell,它似乎会给我一个错误:
invalid nib registered for identifier (historyCellType) - nib must contain exactly one top level object which must be a UITableViewCell instance'
有没有办法解决这个问题?
谢谢!
【问题讨论】:
-
我更喜欢自定义 UITableViewCell 并处理 ipad 和 iphone 信息。 AT cellForRowAtIndexPath at uitableView 处理单元格宽度和高度..
-
@GeorgeHanna 是的,但问题是我需要将最初位于第二行的所有对象转移到第一行。如果我只是创建另一个单元格并使用 AutoLayout 进行所有设置,这似乎更容易
标签: objective-c xcode uitableview xib