美文网首页iOS 知识点A知识点2iOS
关于** Assertion failure in -[UITa

关于** Assertion failure in -[UITa

作者: 杜尚 | 来源:发表于2016-06-07 09:59 被阅读1175次

    如题,当程序崩溃报错为:** 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;

    }

    如果此文帮助了您,请点击喜欢或评论,我会很鸡冻的😳

    转载说明出处😎

    相关文章

      网友评论

      本文标题:关于** Assertion failure in -[UITa

      本文链接:https://www.haomeiwen.com/subject/jnyddttx.html