سؤال

I am developing an iPad application using sdk 5 and storyboard from an already working iPhone app (developed with separete xibs). I understand how storyboard works but I would like to push a view controller with arguments. Button calls logIn2 action like:

   - (IBAction)logIn2: (NSString *)strUser: (NSString *)strPass
{
    userViewController *UserViewController = [[userViewController alloc] initWithNibName:@"userViewController" bundle:nil stringOne:strUser stringTwo:strPass];
    //UserViewController.hidesBottomBarWhenPushed = YES;
    [[self navController] pushViewController:UserViewController animated:YES];
}

this was working properly but with sdk 5 returns an error at first line. How to push view with arguments? Thank you.

هل كانت مفيدة؟

المحلول

If you are saying that you want to convert your app to use Storyboard and Segues then you would make a Segue to push UserViewController. Put some properties in UserViewController to store the arguments. Then override prepareForSegue and set the properties in it. See this answer for more details:

Properly accessing a segue's destination view controller to assign protocol delegates

نصائح أخرى

Pretty obvious from the error message that there isn't a method declare initWithNibName:bundle:stringOne:stringTwo:' on your UserViewController. How is your UserViewController looks like?

Did you declare the custom initializer in your .h file? Otherwise only the standard initWithNibName initializer will be found as selector and not your designated one - hence the error message.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top