首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NSBundle mainBundle给出了sigabrt错误?

NSBundle mainBundle给出了sigabrt错误?
EN

Stack Overflow用户
提问于 2012-05-25 15:01:50
回答 1查看 880关注 0票数 0

我正在使用xCode 4.2构建一个iPhone应用程序。

相关问题--我认为这可能是我正在经历的真正问题:Why does tableView dequeueReusableCellWithIdentifier:CellIdentifier return null?

不过,让我继续讨论这个问题:

当我以某种方式设置rootview控制器时,行[[NSBundle mainBundle] loadNibNamed:@"WSCSessionCell" owner:nil options:nil];会给我一个SIGABRT错误,而不是其他方式。让我从继承了WSCSessionTable的UITableViewController的示例代码开始:

代码语言:javascript
复制
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"WSCSessionCell";

    WSCSessionCell *cell = (WSCSessionCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        NSArray * topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"WSCSessionCell" owner:nil options:nil];

        for(id currentObject in topLevelObjects)
        {
            if([currentObject isKindOfClass:[UITableView class]])
            {
                cell = (WSCSessionCell *) currentObject;
                break;
            }
        }

    }
return cell;
}

场景1-没有问题-没有SIGABRT

当我的NavigationController rootviewcontrols控制WSCSessionTable时,上面的代码工作得很好。下面是我的故事板的样子,以供参考。

场景2-问题,代码导致SIGABRT

当我在导航控制器和UIViewController之间放置一个WSCSessionTable时,上面的代码会导致SIGABRT错误。然后,我使用一个按钮实例化WSCSessionTable。这是我的故事板

这是按钮的事件处理程序。

代码语言:javascript
复制
- (IBAction)goToSession:(id)sender
{
    wscAppDelegate *appDelegate = (wscAppDelegate *)[[UIApplication sharedApplication] delegate];
    UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
    wscSessions *childView = [storyboard instantiateViewControllerWithIdentifier:@"sessionstable"];
//    wscSessions *childView = [storyboard instantiateViewControllerWithIdentifier:@"sessionstable"];
    childView._arrData = appDelegate._arrSession;
    childView._arrSpeaker = appDelegate._arrSpeaker;
    childView.title = @"SEssions";
    [self.navigationController pushViewController:childView animated:YES]; 
    }

在带有nsbundle主包的行中的cellforrowatindexpath函数中,我得到了一个sigabrt错误。这是错误输出

代码语言:javascript
复制
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/dduvernet/Library/Application Support/iPhone Simulator/5.1/Applications/54EF04FD-E010-48BB-A0F4-EB0F12BF8D6A/gmmiphone.app> (loaded)' with name 'WSCSessionCell''
*** First throw call stack:
(0x1da1022 0x2359cd6 0x1d49a48 0x1d499b9 0xa98638 0xa99eb7 0x3d9f 0x911c54 0x9123ce 0x8fdcbd 0x90c6f1 0x8b5d21 0x1da2e42 0x181679 0x18b579 0x1104f7 0x1123f6 0x111ad0 0x1d7599e 0x1d0c640 0x1cd84c6 0x1cd7d84 0x1cd7c9b 0x28f07d8 0x28f088a 0x877626 0x2138 0x2095 0x1)
terminate called throwing an exception(gdb) 

有人知道我如何通过按钮选项卡来实例化WSCSessiontable吗?

相关问题--我认为这可能是我正在经历的真正问题:Why does tableView dequeueReusableCellWithIdentifier:CellIdentifier return null?

EN

回答 1

Stack Overflow用户

发布于 2012-05-25 20:03:41

部分问题是,您正在搜索的是UITableView而不是UITableViewCell。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10756791

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档