在点击后转换页面时,屏幕变黑

时间:2013-06-17 11:09:15

标签: iphone ios objective-c xcode

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

 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 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

我认为您错过了提供NibName

您的代码

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

应该是

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

答案 2 :(得分:0)

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

答案 3 :(得分:0)

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

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

如果笔尖在故事板中 首先将xib的storyboardID设置为NewsDetailViewController,然后使用

NewsDetailViewController *newsdetail=[[self storyboard] instantiateViewControllerWithIdentifier:@"NewsDetailViewController"];
newsdetail.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:newsdetail animated:YES];
相关问题