问题描述
- 点击变换页面后,屏幕黑屏
- 代码:
我使用storyboard:
NewsDetailViewController *newsdetail=[[NewsDetailViewController alloc] initWithNibName:nil bundle:nil];newsdetail.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;[self presentModalViewController:newsdetail animated:YES];
有一个collectionview,从API中抓取数据,然后再放入collectionview中,我希望点击时能得到各个条目的详细信息,但是在点击后屏幕变成黑屏。
输出:
2013-06-17 14:20:30.288 xproject[7511:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException' reason: 'Could not load NIB in bundle: 'NSBundle </Users/sezgindemir/Library/Application Support/iPhone Simulator/6.1/Applications/67BC91AF-5091-4F39-A2BD-CA7E1DD0FEF0/xproject.app> (loaded)' with name 'NewsDetailViewController''*** First throw call stack:(0x1c99012 0x10d6e7e 0x1c98deb 0x236ef9 0xfb7e7 0xfbdc8 0xfbff8 0xfc232 0x107c25 0x3073a3 0x104ee3 0x105167 0x1051a7 0x4c3d 0x51c42f 0x52e182 0x52e394 0x10ea705 0x12893c 0x1289ac 0x10ea705 0x12893c 0x1289ac 0x2e21d3 0x1c61afe 0x1c61a3d 0x1c3f7c2 0x1c3ef44 0x1c3ee1b 0x1bf37e3 0x1bf3668 0x1affc 0x25ed 0x2515)libc++abi.dylib: terminate called throwing an exception(lldb)
解决方案
你这是在使用单独的.xib文件来初始化视图,且你并没有指定xib文件,见你的代码:
NewsDetailViewController *newsdetail=[[NewsDetailViewController alloc] initWithNibName:nil bundle:nil];
initWithNibName 参数的值此处是nil . 在使用xib初始时需要指明xib文件的名,如
NewsDetailViewController *newsdetail=[[NewsDetailViewController alloc] initWithNibName:@""NewsDetailView"" bundle:nil];
但前提是你需要有一个名为NewsDetailView.xib的文件
时间: 2024-08-29 09:48:59