我想要使用自定义的UITableViewCell,并且将它放在与UITableView控制器相同的nib文件中。为此,这些文件是:NTItems.h,NTItems.m和NTItems.xib。自定义单元格只失败
我已经定义在头文件中的单元格:
IBOutlet UITableViewCell *cellview;
,我已经正确地应用属性:非原子,留住了它的存在:
@property (nonatomic, retain) IBOutlet UITableViewCell *cellview;
在M文件 - 我已合成可变设备,并使用此来获取定制单元:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"cellview";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = self.cellview;
}
Product *aProduct = [appDelegate.products objectAtIndex:indexPath.row];
name.text = aProduct.name;
upc.text = [NSString stringWithFormat:@"UPC%@",aProduct.upc];
price.text = aProduct.pid;
return cell;
}
但是,当我装载表,我得到这个乌七八糟:
alt text http://dl.dropbox.com/u/1545603/tablecellissue.png
应该有展示以及数据超过1个细胞。看来只有最后的数据现在正在显示。
如果你可以提供一些更好的上下文代码。 – 2010-04-08 22:25:14
是的,增加了更多:) – bear 2010-04-08 22:40:05