popViewController does not remove viewController

Discussion in 'iOS Programming' started by fbartolom, Jan 29, 2014.

  1. fbartolom macrumors newbie

    Joined:
    Jan 29, 2014
    #1
    I am having a problem with my iPad app in dismissing view controllers in the master detail. When I try to pop them up just the title gets popped, while the table remains there. If I push another view controller again the title is updated but the table remains the old one. If finally I refresh the table by pulling it down, lo and behold, the new table surfaces. Logging the view controllers evolution in the navigation controller nothing strange shows up: upon popping up the navigation controller just owns the root view controller. I am really stuck as it seems my popping up has no effect on the view controller content.

    Thanks in advance
     
  2. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #2
    You need to provide a LOT more information.

    What is the structure of your app? Is the root of all your view controllers a navigation controller? What is its root view controller?

    What is the code that pushes other view controllers, and what is the code the does the popping?

    Are you using storyboards or nib files?
     
  3. fbartolom thread starter macrumors newbie

    Joined:
    Jan 29, 2014
    #3
    Sure, the iPad project is a simple SplitViewController and the "unpoppable" controllers are on the master part. You may have a look yourself at the storyboard at:
    http://www.inarrivo.net/uk/storyboards/
    The master view controller has its own navigation controller on which I push the new controllers and from which I would like to pop them up.
    The pushing is done through the storyboard while the popping up is done with the following piece of code:
    Code:
    - (void) dismissView:(id)sender {
    		// Call the delegate to dismiss the modal view
        inArrivoHDAppDelegate* appDelegate = (inArrivoHDAppDelegate*)[[UIApplication sharedApplication] delegate];
        NSLog(@"controllers %@", appDelegate.rootViewController.navController.viewControllers);
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
            [appDelegate.rootViewController.navController popViewControllerAnimated:YES];
        } else {
            [self.navigationController popViewControllerAnimated:YES];
        }
        NSLog(@"after count %ld", (unsigned long)[appDelegate.rootViewController.navController.viewControllers count]);
        NSLog(@"controllers %@", appDelegate.rootViewController.navController.viewControllers);
    }
    
    The root controller is loaded in the appDelegate with:
    Code:
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
            splitViewController = (UISplitViewController *)self.window.rootViewController;
            UINavigationController *navigationController = [splitViewController.viewControllers objectAtIndex:0];
            rootViewController =(RootViewController*)[navigationController topViewController];
            rootViewController.navController=navigationController;
            detailViewController=(inArrivoHDDetailViewController*)[splitViewController.viewControllers lastObject];
            splitViewController.delegate = (id)navigationController.topViewController;
            detailViewController.delegate=(UITableViewController*)navigationController.topViewController;
            navigationController.navigationBar.barStyle=UIBarStyleBlack;
        }
    
    The formers.
     

Share This Page