我有用IB创建的uitableview。我设计了我自己的uitableviewcell(它是uiatbleviewcell的子类,并有自己的xib文件)。如何将它添加到我的uitableview?如何将自定义的uitableviewcell添加到用ib创建的uitableview?
我试图
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
*)indexPath {
static NSString *CellIdentifier = @"myCell";
myCell *cell = (myCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *xib = [[NSBundle mainBundle] loadNibNamed:@"myCell" owner:self options:nil];
cell = [xib objectAtIndex:0];
}
// Configure the cell...
cell.title.text = @"tableCell";
cell.preview.text = @"preview";
cell.postedTime.text = @"right now";
return cell;
}
它的工作原理不正确。我不能在这里包含图片,因为我的代表是10(最少需要11才能上传图片)。所以这里的链接显示我的坏结果。这就是我想要的:http://img708.imageshack.us/img708/5082/20120903153930.png
这是我有: http://img836.imageshack.us/img836/5844/20120903154405.png
单击单元格....打开Identity Inspector并将自定义单元格的类更改为“myCell”。然后附上奥特莱斯。也许它会帮助你... –