Search code examples
iphoneiosobjective-cxcodeuipopovercontroller

Navigate to another window from a popup in iPhone


I used this SampleCode and created two pop-ups, say pop-up1 and pop-up2. From Pop-up1 if a button is pressed another pop-up2 will be displayed. From po-pup2 I need to go for another view. Till pop-up2 its fine, from pop-up2 I couldn't go for a separate view?

I used the below code to remove the popupview.

[self dismissPopupViewControllerWithanimationType:MJPopupViewAnimationFade];
    imageShareSubViewController = nil;

I used used the below code to navigate to another view.

@autoreleasepool {
        ViewController *obj = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]autorelease];
        [self.navigationController pushViewController:obj animated:TRUE];
        obj = nil;
    }

But the above is not working fine ( i.e., i could navigate to another view ). How to solve this? Am I wrong anywhere?


Solution

  • create your navigationController, setRootViewController just like this:

    //A view controller:
    HomeScreen * homeScreen = [[HomeScreen alloc]initWithNibName:@"HomeScreen" bundle:nil];
    
    UINavigationController* navigation = [[UINavigationController alloc]initWithRootViewController:homeScreen];
    
    AppDelegate * delegate = (AppDelegate*)[[UIApplication sharedAplication]delegate];
    delegate.window.rootviewcontroller = navigation;
    [homeScreen release];
    
    //add other views
    
    HomeScreen * homeScreen2 = [[HomeScreen alloc]initWithNibName:@"HomeScreen" bundle:nil];
    
    [navigation pushViewController: homeScreen2];
    [homeScreen2 release];