1

我有关联到一个UIViewController定制类XIB文件(ZocaloPlayerViewController)现在视图控制器模态,从厦门国际银行文件

enter image description here

和IM试图提出一个UIViewController(在故事板制作)模态与水平翻转

enter image description here

,但我得到一个错误:

这是我尝试如何呈现视图控制器

ShowDetailsArtistAlbumViewController *vc = [[ShowDetailsArtistAlbumViewController alloc] initWithNibName:@"ShowDetailsArtistAlbumViewController" bundle:nil]; 
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
[self presentViewController:vc animated:YES completion:^{ 

}]; 

但我得到这个错误...

Uncaught exception: Could not load NIB in bundle: 'NSBundle </var/mobile/Containers/Bundle/Application/57C2AD20-51DB-4C43-BB8F-2E8F22CD2E2A/MyMusicApp.app> (loaded)' with name 'ShowDetailsArtistAlbumViewController' 

我与

[self.parentViewController presentViewController:vc animated:YES completion:^{ 

}]; 

努力,但没有任何反应..

编辑: 我试过这种方式

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
ShowDetailsArtistAlbumViewController *vc = [sb instantiateViewControllerWithIdentifier:@"ShowDetailsArtistAlbumViewController"]; 
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
[self presentViewController:vc animated:YES completion:^{ 

}]; 

视图控制器呈现,但即时得到内部

回答

1

黑色的观点,但没有你说“我有关联的厦门国际银行文件”,但问题是,你不知道。运行时正在寻找名为的xib文件ShowDetailsArtistAlbumViewController.xib但您没有。您需要重命名您的xib文件以符合运行时期望。

或者,您可能会错误地创建视图控制器。你是说这个:

ShowDetailsArtistAlbumViewController *vc = 
    [[ShowDetailsArtistAlbumViewController alloc] 
     initWithNibName:@"ShowDetailsArtistAlbumViewController" bundle:nil]; 

这就是为什么运行时会认为你有一个笔尖称为ShowDetailsArtistAlbumViewController.xib - 你是,就在那里告诉它在该行!

这很好,如果实际上有一个叫做的笔尖,ShowDetailsArtistAlbumViewController.xib。你的问题是没有。你欺骗了运行时,所以自然会崩溃。

如果你确实想在故事板使用视图控制器,这如何访问该实例。你正在做的是创建一个不同的实例。如果你想要故事板中的实例,你需要与故事板对话并告诉它instantiateViewControllerWithIdentifier:

+0

我正在解释自己错了。我想要呈现的视图控制器是在故事板中制作的。看看我的问题编辑。 – Quetool

+0

你不听我说的话。视图控制器如何实例化并不重要。该错误消息意味着运行时正在寻找称为_ShowDetailsArtistAlbumViewController.xib_的xib文件,但您没有。 – matt

+0

马特,我明白了,但如果视图控制器是在故事板,我必须把笔尖名称?请看我编辑图像的问题... – Quetool