代碼:
我使用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的文件