【发布时间】:2012-01-28 06:53:54
【问题描述】:
在两个类中,我对 UITableViewCell 进行了子类化,以便进行一些主要的自定义。我想使用 Xib 文件将 UI 布局代码的数量保持在最低限度。我遇到了一个奇怪的例外:
if (!cell) {
if (indexPath.row == 0) {
cell = [[[SearchCellTop alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
NSArray* objects = [[NSBundle mainBundle] loadNibNamed:@"SearchCellTop" owner:cell options:nil];
cell = (SearchCellTop*)[objects objectAtIndex:0];
}
else {
cell = [[[SearchCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
NSArray* objects = [[NSBundle mainBundle] loadNibNamed:@"SearchCell" owner:cell options:nil];
cell = (SearchCell*)[objects objectAtIndex:0];
}
}
这似乎适用于加载 Xib。但是,一旦我尝试执行以下操作:
if (indexPath.row < [self tableView:tableView numberOfRowsInSection:indexPath.section])
((SearchCell*)cell).Product = [products objectAtIndex:indexPath.row];
我得到 -[UIAccessibiltyBundle setProduct:] 无法识别的选择器发送到实例
一切都表明“单元格”的类型正确,但我仍然收到此错误。
【问题讨论】:
标签: iphone ios uitableview