i have a problem while calling a navigation method from a presented modal view.
i have three view controllers, HomeViewController,loadViewController, modalViewController.
modalViewController presented as a moda view from HomeViewController by a button press. actually what i need is , when i press a button from presented modalViewController , modal view should be dismissed and the HomeViewController should navigate to loadViewController.
its not working with my code,
HomeViewController.m
- (IBAction)shortCutButtonPressed:(id)sender {
ShortCutViewController *viewController=[[ShortCutViewController alloc]initWithNibName:nil bundle:nil];
[self.navigationController presentModalViewController:viewController animated:YES];
[viewController release];
}
-(void)loadViewControllerLoad
{
loadViewController *loadView=[[loadViewController alloc]initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:loadView animated:YES];
[loadView release];
}
modalViewController.m
//modal view controller will call the function loadViewControllerLoad from HomeViewController to navigate homeview to loadView. function call reaches correctly but the view is not navigating to loadView
- (IBAction)HomeButtonPressed:(id)sender {
homeView=[[HomeViewController alloc]initWithNibName:nil bundle:nil];
[homeView loadViewControllerLoad];
[[self presentingViewController] dismissModalViewControllerAnimated:YES];
[homeView release];
}
function call reaches at HomeViewController but the view doesn’t navigating to LoadView?
i see… your implementation is incorrect.When you are allocating your HomeViewController object in modalViewController.m , so the self.navigationController and all other properties of HomeViewController will be nil when calling loadViewControllerLoad method…So Don’t create a new object of HomeViewController . Get the object through any other way.. pass it or use propery to get the HomeViewController object from your modalViewController to call the method “loadViewControllerLoad”
Use .nib file Names to initialize your view instead of setting it to nil.
Example:
Apply this for loadViewController and HomeViewController too…