如题,当程序崩溃报错为:** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.30.14/UITableView.m:7962 😧😧😧一脸蒙13
莫慌!莫慌!莫慌!
你一定在viewController中的添加tableView了吧👀
第一,要检查一下这个方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{}
是不是没有写这个方法,或者返回值给的是return nil。
第二,如果写了这个方法,但是还是崩溃,那就要给你个必杀技!!!
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier =@"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
////// ***************************
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
}
////// *****************************
cell.textLabel.text = [arrayname objectAtIndex:indexPath.row];
cell.textLabel.backgroundColor=[UIColor clearColor];
cell.textLabel.textColor=[UIColor redColor];
return cell;
}
如果此文帮助了您,请点击喜欢或评论,我会很鸡冻的😳
转载说明出处😎