zoukankan      html  css  js  c++  java
  • tableView Crash

    转自:http://blog.csdn.net/hamasn/article/details/8613593

    Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:]

    今天做一个tableView遇到一个这么个问题。

    经过baidu google,终于找到正解。

    因为

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath     *)indexPath
    这个函数的返回值是个null!!
    查stackoverflow 找到下面的解。

    CellIdentifier I bet your cellForRowAtIndexPath is returning null.

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath     *)indexPath
    {
        static NSString *CellIdentifier = @"Photos";
    
        /** NOTE: This method can return nil so you need to account for that in code */
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
        // NOTE: Add some code like this to create a new cell if there are none to reuse
        if(cell == nil)
        {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    
        }
    
        NSString *string = [[self.photosInPlace objectAtIndex:indexPath.row]     valueForKeyPath:@"description._content"];
    
        cell.textLabel.text = string;
    
        return cell;
    }

    That's probably why [UITableView _configureCellForDisplay:forIndexPath:] is failing... becausecellForRowAtIndexPath is returning a null value and then configureCellForDisplay is expecting aUITableViewCell.

  • 相关阅读:
    Windows Azure Cloud Service (5) 由过渡环境向生产环境过渡
    rpcss.dll丢失造成任务栏不见
    css文本省略号
    字符串是否包含中文?
    在 System.NullReferenceException 中第一次偶然出现的“ComServer.exe”类型的异常
    取参数的正则表达式
    EverNote死机的问题
    找尺子
    读书笔记
    水晶按钮的学习
  • 原文地址:https://www.cnblogs.com/LiuLady12138/p/4696516.html
Copyright © 2011-2022 走看看