1

这是我的代码:
我使用故事板

 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) 
4

4 回答 4

0

您没有正确加载视图控制器。

试试这个代码:

UIViewController *vc=[[self storyboard] instantiateViewControllerWithIdentifier:@"NewsDetail"];//you have to give it this name (or any) in the storyboard

    [self.navigationController pushViewController:vc animated:YES];

确保你有一个 uinavigationController 控制自我

于 2013-06-17T11:16:04.430 回答
0

我想你错过了提供NibName

你的代码

NewsDetailViewController *newsdetail=[[NewsDetailViewController alloc] initWithNibName:nil bundle:nil];

它应该是

NewsDetailViewController *newsdetail=[[NewsDetailViewController alloc] initWithNibName:@"YOUR_NIB_NAME" bundle:nil];
于 2013-06-17T11:16:12.343 回答
0

使用这个 - NewsDetailViewController *news detail = [[NewsDetailViewController alloc] init];

于 2013-06-17T11:19:47.743 回答
0

故事板中 NewsDetailViewController 的 xib 还是单独的 xib?

如果它是单独的 xib,请确保您的 xib 名称是 NewsDetailViewController.xib。然后它应该工作。

如果笔尖在情节提要中,首先将 xib 的情节提要设置为NewsDetailViewController,然后使用

NewsDetailViewController *newsdetail=[[self storyboard] instantiateViewControllerWithIdentifier:@"NewsDetailViewController"];
newsdetail.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:newsdetail animated:YES];
于 2013-06-17T11:32:02.313 回答