导航控制器以编程方式查看控制器不工作IOS7

时间:2014-03-17 05:08:42

标签: ios iphone objective-c uinavigationcontroller

您好,在我的应用程序中,我有导航控制器注册,如果用户在注册表单中输入无效数据,我会对我的注册表单进行验证,如果用户不能移动到下一个视图控制器,正确的数据,它应该移动到下一个视图控制器,但它不起作用。

     - (IBAction)reg:(id)sender {
   if ([self validateEmail:[email text]]== 1 && [self phonevalidate:[phone text]]== 1 && [name.text length] <= 25 && [city.text length] <= 25 ) {
       pollpoliticalViewController *pollVC = [[UIStoryboard storyboardWithName:@"Main.storyboard" bundle:nil] instantiateViewControllerWithIdentifier:@"PollPoliticalVCID"];
       [self.navigationController pushViewController:pollVC animated:YES];
       UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Thanks For The Registration" delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil];
       [alert show];
       [alert release];


    }else{
       UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:@"Message" message:@"you entered worng correct" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
       [alert1 show];
       [alert1 release];
    }
  }

我使用上面的代码进行导航,以编程方式从导航控制器中查看控制器,但是给出的错误就像。

  

由于未捕获的异常终止应用&#39; NSInvalidArgumentException&#39;,原因:&#39;无法找到名为&#39; Main.storyboard&#39;

的故事板

但我的故事板名称是main.storyboard我不知道为什么它给出了这样的错误我试图通过链接故事板名称,但是我改变了它给同样的错误请告诉我如何解决这个。

感谢。

1 个答案:

答案 0 :(得分:0)

故事板名称不包含扩展程序,请尝试使用Main代替Main.storyboard

pollpoliticalViewController *pollVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"PollPoliticalVCID"];


来自官方documentation

为指定的故事板资源文件创建并返回storyboard对象。

+(UIStoryboard *)storyboardWithName:(NSString *)name bundle:(NSBundle *)storyboardBundleOrNil

参数name 没有文件扩展名的storyboard资源文件的名称。如果此参数为nil,则此方法引发异常。 [...]