简体   繁体   English

导航控制器以编程方式查看控制器无法运行IOS7

[英]Navigation Controller to View Controller Programmatically Not Working IOS7

Hi in my application i have navigation controller with registration and I'm doing the validation for my registration form if user enter a invalid data in the registration form it should not move to the next view controller and if user give the right data it should move to the next view controller but its not working. 嗨,在我的应用程序中,我具有注册的导航控制器,并且如果用户在注册表单中输入无效数据,则我将对我的注册表单进行验证,它不应移至下一个视图控制器,并且如果用户提供正确的数据,则应移至下一个视图控制器到下一个视图控制器,但无法正常工作。

     - (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];
    }
  }

I used this above code for the navigating to view controller form the navigation controller programmatically but its giving error like. 我将以上代码用于导航,以编程方式从导航控制器中查看视图控制器,但出现类似错误。

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Main.storyboard' 由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'找不到名为'Main.storyboard'的故事板

But my storyboard name is main.storyboard i don't know why its giving error like this i have tried to by chaining the storyboard name but what ever i change the its giving the same error for all please tell me how to resolve this one. 但是我的情节提要板名称是main.storyboard,我不知道为什么我试图通过链接情节提要板名称来尝试这样的给错,但是我改变了它给所有人带来的相同错误,请告诉我如何解决这个问题。

Thanks. 谢谢。

The storyboard name does not contain the extension, try using Main instead of Main.storyboard 情节Main.storyboard名称不包含扩展名,请尝试使用Main代替Main.storyboard

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


From the official documentation : 从官方文档中

Creates and returns a storyboard object for the specified storyboard resource file. 为指定的情节提要资源文件创建并返回一个情节提要对象。

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

Parameters name The name of the storyboard resource file without the filename extension . 参数name 故事板资源文件的名称,不带文件扩展名 This method raises an exception if this parameter is nil. 如果此参数为nil,则此方法引发异常。 [...] [...]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM