我正在使用自定義單元格(This site)。這是在我的舊應用程序的工作,但在這個應用程序,我不知道爲什麼它沒有工作,當我運行上面的代碼,他卡在綠色錯誤行(NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
)。Iphone:使用表格自定義單元格
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
CellIdentifier = @"CustomCell";
PCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil){
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (PCustomCell *) currentObject;
break;
}
}
}
P2Dict = [P2Rows objectAtIndex: indexPath.row];
cell.Contracts.text = [P2Dict objectForKey:@"Contracts"];
return cell;
}
你有你的新項目名爲CustomCell一個的.xib文件? – Eyal 2012-08-09 17:31:00
http://ar2.co/SS2.png – user1526898 2012-08-09 17:32:02
PCustomCell.xib – user1526898 2012-08-09 17:32:21