How can I push a view controller to another view controller that does not have a nib file?

advertisements

How would I go about pushing oneviewcontroller to another viewcontroller that doesn't have a nib file?

this is what I'm currently doing. There is no nib file for UserViewController though and yet I'm still using initWithNibName:@"UserViewController"

-(IBAction)userProfile:(id)sender {

    UserViewController *userViewController = [[UserViewController alloc]
                                                            initWithNibName:@"UserViewController" bundle:nil];
    [self.navigationController pushViewController:userViewController animated:YES ];

    [userViewController release];  

}

thanks for any help!!!


If you don't have any nib file you should not mention any. Please find below code :

-(IBAction)userProfile:(id)sender {

UserViewController *userViewController = [[UserViewController alloc]
                                                        init];
[self.navigationController pushViewController:userViewController animated:YES ];

[userViewController release];  

}

You can place -(id)init method in UserViewController and set global variables.