Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 单击后切换页面时,屏幕变黑_Iphone_Ios_Objective C_Xcode - Fatal编程技术网

Iphone 单击后切换页面时,屏幕变黑

Iphone 单击后切换页面时,屏幕变黑,iphone,ios,objective-c,xcode,Iphone,Ios,Objective C,Xcode,这是我的密码: 我喜欢使用故事板 NewsDetailViewController *newsdetail=[[NewsDetailViewController alloc] initWithNibName:nil bundle:nil]; newsdetail.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:newsdetail animated:YES

这是我的密码: 我喜欢使用故事板

 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) 

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

请尝试以下代码:

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控制自己

我想您没有提供NibName

你的代码

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

NewsDetailViewController *newsdetail=[[NewsDetailViewController alloc] initWithNibName:@"YOUR_NIB_NAME" bundle:nil];
用这个-
NewsDetailViewController*news detail=[[NewsDetailViewController alloc]init]

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

如果是单独的xib,请确保您的xib名称为NewsDetailViewController.xib。那么它应该会起作用

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

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

屏幕返回是什么意思?首先检查newsdetail视图控制器是否正在加载,即它不是零。检查NewsDetailViewController.xib文件的目标成员身份