IOS 7:

Exception Detail: *** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit/UIKit-2935.137/UITableView.m:6509


码:



- (void)viewDidLoad {
[super viewDidLoad];
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, UISIZE.width, UISIZE.height -64) style:UITableViewStylePlain];
self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
self.tableView.delegate = self;
self.tableView.dataSource = self;

self.tableView.tableFooterView = [[UIView alloc] init];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

[self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([GWVipRechargeCell class]) bundle:nil] forCellReuseIdentifier:@"GWVipRechargeCell"];
[self.view addSubview:self.tableView];


}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
GWVipRechargeCell * cell = [tableView dequeueReusableCellWithIdentifier:@"GWVipRechargeCell"];
if (cell == nil) {
    cell = [tableView dequeueReusableCellWithIdentifier:@"GWVipRechargeCell"];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;


}

我发现异常断点跳转到self.tabelView.separatorStyle = UITableViewCellSeparatorStyleNone;

一些tabelview集:

self.tabelView.dataSource = self;
self.tabelView.delegate = self;
self.tabelView.tableFooterView = [[UIView alloc] init];
self.tabelView.separatorStyle = UITableViewCellSeparatorStyleNone;


我尝试了iOS 5 Storyboard Custom Cell Crash: UITableView dataSource must return a cell的所有答案,但仍然在self.tabelView.separatorStyle = UITableViewCellSeparatorStyleNone;崩溃

解:
 我移动设置顺序

self.tabelView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tabelView.tableFooterView = [[UIView alloc] init];


运行成功!我也很困惑!!!

如果我设置tableHeaderView也有这个问题

最佳答案

 [self.YOURTABLEVIEW registerNib:[UINib nibWithNibName:@"YOURCUSTOMCELL" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"YOURCUSTOMCELL_IDENTIFIER"];

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YOURTABLEVIEWCELL_CLASS *cell = [tableView dequeueReusableCellWithIdentifier:@"YOURTABLEVIEWCELL_IDENTIFIER"];

    if (cell == nil) {

       NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"YOURTABLEVIEWCELL_IDENTIFIER" owner:self options:nil];
       cell = [topLevelObjects objectAtIndex:0];
    }
    // here write your cell coding like give value to your lable, image , etc.
    return cell;
}

10-06 02:54