4

I Show a view using presentModalViewController. and from this UIView I want to push a UIView using UINavigationController. I tried below code for this

[self.parentViewController.navigationController 
                pushViewController:objViewFullScreen 
                          animated:YES];

But it did not works for me. so please can any one suggest how I push a view from ModelViewController.

Thanks

Alex Cio
  • 6,014
  • 5
  • 44
  • 74
Mitesh Khatri
  • 3,935
  • 4
  • 44
  • 67

2 Answers2

8

First you have to present your modal view controller inside a navigation controller:

MyViewController *vc = [[MyViewController alloc] initWithNibName:@"MyNib" bundle:nil];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:vc];

[self presentModalViewController:nc animated:YES];

[vc release];
[nc release];

Then inside MyViewController you can do:

OtherViewController *vc = [[OtherViewController alloc] initWithNibName:@"MyOtherNib" bundle:nil];
[self.navigationController pushViewController:vc animated:YES];
[vc release];
ySgPjx
  • 10,165
  • 7
  • 61
  • 78
  • Thanks for quick reply. it works for me. but the vc view is not transparent. i also set the [uicolor clearcolor] but it not works for me. so can you suggest me how i make it transparent. Thx – Mitesh Khatri Jul 21 '11 at 09:16
  • http://stackoverflow.com/questions/849458/transparent-modal-view-on-navigation-controller/859215#859215 – ySgPjx Jul 21 '11 at 10:09
0
-(void)pushViewControllerWithCustomAnimation:(UIViewController *)newViewController {
    newViewController.view.alpha = 0.0f;
    [self.view addSubview:newViewController.view];

    [UIView animateWithDuration:1
                     animations:^{
                         newViewController.view.alpha = 1;
                     }
                     completion:^(BOOL fin){
                         if (fin) {
                             // finally display the new viewcontroller for real
                             [self.navigationController pushViewController:newViewController animated:NO];
                         }
                     }];
}
Rob
  • 4,927
  • 12
  • 49
  • 54
Bhushan_pawar
  • 157
  • 1
  • 5