尝试从TableView传递到UIWebview会导致崩溃

时间:2013-02-11 23:23:43

标签: iphone uiwebview storyboard

正如你在标题中看到的那样,我有一个小问题。我使用MWParser作为RSS提要。我编辑了点击RSS标题时的代码,它在应用内浏览器中打开。 这是代码:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (_webViewController == nil) {
        self.webViewController = [[[WebViewController alloc] initWithNibName:@"WebViewController" bundle:[NSBundle mainBundle]] autorelease];
    }

    MWFeedItem *entry = [parsedItems objectAtIndex:indexPath.row];
    _webViewController.entry = entry;
    [self.navigationController pushViewController:_webViewController animated:YES];


    // Deselect
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];

}

但是,我收到此崩溃消息:

2013-02-11 18:21:15.644 GlennKessler[24209:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/Hugo/Library/Application Support/iPhone Simulator/6.1/Applications/7F35D6C0-BFBE-4CD9-A1CE-7DC54CD6B249/GlennKessler.app> (loaded)' with name 'WebViewController''

据我所知,这种情况正在发生,因为我使用的是Storyboard,而不是NIB。如何在故事板中打开WebViewController中代码的视图?谢谢!

1 个答案:

答案 0 :(得分:0)

将[NSBundle mainBundle]替换为nil,因为nib在默认包中,并确保nib文件(WebViewController.nib)位于打包应用程序的Bundle中

相关问题