错误:不包含带标识符的视图控制器?

问题描述:

-(void)btnclick1:(UIButton *)sender 
{ 
    NSString *[email protected]"Main"; 

    UIStoryboard* storyboard1 = [UIStoryboard storyboardWithName:storyboardName 
                 bundle:nil]; 


    secondViewController *add = [[secondViewController alloc]init]; 
add =[storyboard1 instantiateViewControllerWithIdentifier:@"nextseg"]; 
    [self.view addSubview:add.view]; 

    [self presentViewController:add 
         animated:YES 
        completion:nil]; 



} 

我得到错误:原因:“故事板()不包含一个视图控制器与标识符‘nextseg’”错误:不包含带标识符的视图控制器?

+0

您是否向storyboard中的视图控制器提供了标识符?换句话说,从你得到这个的地方,什么是“nextseg”? – CRDave 2014-10-27 06:47:44

+0

尝试此链接http://stackoverflow.com/questions/23102978/swrevealviewcontroller-without-using-navigationcontroller/23105142#23105142 – 2014-10-27 07:03:45

您需要设置Storyboard ID您要在MainStoryboard设置要使用的厦门国际银行XIB,见图片。你的情况应该是@"nextseg"

enter image description here

希望这有助于。

干杯。

只需将[NSBundle mainBundle]添加到您从中获取故事版的包参数。希望这有帮助

-(void)btnclick1:(UIButton *)sender 
{ 
    NSString *[email protected]"Main"; 

    UIStoryboard* storyboard1 = [UIStoryboard storyboardWithName:storyboardName 
                bundle:[NSBundle mainBundle]]; 


    secondViewController *add = [[secondViewController alloc]init]; 
    add =[storyboard1 instantiateViewControllerWithIdentifier:@"nextseg"]; 
    [self.view addSubview:add.view]; 

    [self presentViewController:add 
        animated:YES 
       completion:nil]; 



} 

此外,请确保您的视图控制器有一个标识符“nextseg”。 “nextseg”不应该是通向视图控制器的segue的标识符,但它应该用于视图控制器