ios - objective-c : dequeueReusableCellWithIdentifier:forIndexPath: returns exception

标签 ios objective-c storyboard uitableview

<分区>

我在 Storyboard中制作了我的原型(prototype)单元格并设置了它的标识符,但是当我调用

cell=[tableView dequeueReusableCellWithIdentifier:@"ident" forIndexPath:indexPath];

在我的 cellForRowAtIndexPath 方法中出现异常:

 unable to dequeue a cell with identifier ident - must register a nib or a class for the identifier or connect a prototype cell in a storyboard

现在,我知道,如果我在 Storyboard 中声明一个原型(prototype)单元,我不需要显式注册它。 那么……为什么会出现这个异常?

更新: 我发布了两张有显示问题的图片: enter image description here enter image description here

最佳答案

尝试做这些..

删除这些..

NSString *identificatore=@"voce";

然后做这些..

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
    static NSString *yourcellidentifier=@"cella_opzioni_menu";//here write the cell identifier you gave in storyboard..

    cell=[tableView dequeueReusableCellWithIdentifier:yourcellidentifier];

    if(cell == nil)
    {
         ........
    }

    .
    .
    .

}

希望对你有帮助

关于ios - objective-c : dequeueReusableCellWithIdentifier:forIndexPath: returns exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32566106/

上一篇:ios - 使用 swift 发起 HTTP GET 请求

下一篇:ios - 打开/关闭 View 作为菜单

相关文章:

wpf - 找不到 EventTrigger.SourceName

iphone - 为什么使用我的自定义类会导致内存错误?

ios - Swift - 广告只是应用程序上的一个白条

IOS MBProgressHUD显示位置错误(不是居中,加载显示在左上角。)

objective-c - 如何使用 subview 对缩放 UIView 进行动画处理?

objective-c - 从 imp 调用 Objective-C 方法

objective-c - NSView CALayer 不透明度疯狂

ios - 如何知道 segue 是推送还是模态

ios - Objective-C 属性和实例变量

ios - 使用 UIViewController 动画显示 UINavigationController