http://www.iphonedevsdk.com/forum/iphone-sdk-development/9102-assertion-failure-uitableview.html

2011-08-18 17:27:23.151 Encompass[49519:207] *** Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit_Sim/UIKit-1447.6.4/UITableView.m:5613

    static NSString *CellIdentifier = @"Cell";
static NSString *CellIdentifier2 = @"Cell2";

UITableViewCell
*cell = nil;

if (indexPath.row == 0) {

cell
= [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell
= [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle
= UITableViewCellSelectionStyleNone;
////
// UILabel *fromOrToLabel = [UIControlUtil tableViewCellTextLabel:CGRectMake(10, 0, 73, 32)];
// fromOrToLabel.textAlignment = UITextAlignmentCenter;
// fromOrToLabel.textColor = [UIColor grayColor];
// fromOrToLabel.tag = 1;
// [cell.contentView addSubview:fromOrToLabel];
//
// UILabel *userLabel = [UIControlUtil tableViewCellTextLabel:CGRectMake(85, 0, 200, 32)];
// userLabel.tag = 2;
// [cell.contentView addSubview:userLabel];
//
// UIView *contentWrap = [[[UIView alloc] initWithFrame:CGRectMake(10, 32, 300, 18 * 6)] autorelease];
// contentWrap.autoresizingMask = UIViewAutoresizingFlexibleWidth;
// contentWrap.backgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1];
//
// UILabel *contentLabel = [UIControlUtil tableViewCellTextLabel:CGRectMake(10, 0, 280, 18 * 6)];
// contentLabel.font = [UIFont systemFontOfSize:14.0];
// contentLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
// contentLabel.textAlignment = UITextAlignmentLeft;
// contentLabel.numberOfLines = 0;
// contentLabel.tag = 3;
// [contentWrap addSubview:contentLabel];
// [cell.contentView addSubview:contentWrap];
//
// UILabel *timeLabel = [UIControlUtil tableViewCellTextLabel:CGRectMake(160, 0, 150, 32)];
// timeLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
// timeLabel.textColor = [UIColor grayColor];
// timeLabel.tag = 4;
// [cell.contentView addSubview:timeLabel];

}

// UILabel *lbFromOrTo = (UILabel *)[cell.contentView viewWithTag:1];
// UILabel *lbUser = (UILabel *)[cell.contentView viewWithTag:2];
// UILabel *lbContent = (UILabel *)[cell.contentView viewWithTag:3];
// UILabel *lbTime = (UILabel *)[cell.contentView viewWithTag:4];

// lbFromOrTo.text = EILocalizedString(@"Response");
// self.mySegmentedControl = segmentedControl;
// self.receive = receiveLabel;
// self.response = responseLabel;
// self.ShowMessage = ShowMessageTextView;
// self.MessageResponse = MessageResponseTextView;
// lbUser.text = ;
// lbContent = receive;
// lbTime = response;
}
else {
//
// cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
// if (cell == nil) {
//
// cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier2] autorelease];
// cell.selectionStyle = UITableViewCellSelectionStyleNone;
//
// UILabel *responseLabel = [UIControlUtil tableViewCellTextLabel:CGRectMake(10, 0, 86, 32)];
// responseLabel.textAlignment = UITextAlignmentCenter;
// responseLabel.textColor = [UIColor grayColor];
// responseLabel.tag = 4;
// [cell.contentView addSubview:responseLabel];
//
// UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(10, 32, 300, (60 * 3) - 52)];
// textView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
// textView.layer.borderWidth = 1;
// textView.layer.borderColor = [[UIColor lightGrayColor] CGColor];
// textView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
// textView.font = [UIFont fontWithName:@"Arial" size:18];
// textView.returnKeyType = UIReturnKeyDone;
// textView.tag = kReplyTextViewTag;
// [cell.contentView addSubview:textView];
// [textView release];
// }
//
// UILabel *lbResponse = (UILabel *)[cell.contentView viewWithTag:4];
// lbResponse.text = [NSString stringWithFormat:@"%@ :", EILocalizedString(@"Response")];
//
// UITextView *textView = (UITextView *)[cell.contentView viewWithTag:kReplyTextViewTag];
// textView = MessageResponse;
}
return cell;

  诡异的错误。本来没问题,不知道怎么回事。除了错误

原因:

 - (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {

return 5;

}  

 5  行  然而只给其中  3行赋值

作者: zhzenghui 发表于 2011-08-18 17:30 原文链接

推荐.NET配套的通用数据层ORM框架:CYQ.Data 通用数据层框架
新浪微博粉丝精灵,刷粉丝、刷评论、刷转发、企业商家微博营销必备工具"