user2514963
user2514963

Reputation: 156

ios navigation error using button

I am trying to go from login screen to signup. But getting error...

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target .'

Login.H

#import "SignupController.h"

@interface LoginController : UIViewController {

IBOutlet SignupController *signupController;

Login.M

(IBAction)signup:(UIButton*) sender
{
    NSLog(@"lla"); 
        [self presentModalViewController:signupController animated:YES];

}

Upvotes: 1

Views: 77

Answers (2)

neohope
neohope

Reputation: 1832

if you donot use a nib file:

signupController = [[SignupController  alloc] init];
[self presentModalViewController:signupController animated:YES];

if you use a nib file:

signupController = [[SignupController  alloc] initWithNibName:@"nib file name with out ext" bundle:nil];
[self presentModalViewController:signupController animated:YES];

Upvotes: 1

Sebastian Flückiger
Sebastian Flückiger

Reputation: 5555

you need to allocate and initiate your signupController first.

self.signupController = [[SignupController alloc]initWithNibName:xibname];
[self presentModalViewController:signupController animated:YES];

wheras xibname is will be the name of your nibfile, somthing like @"signupController" if your interface file is called signupController.xib

sebastian

Upvotes: 2

Related Questions