Question

Here are the relevant lines of code: ...

       if([top class] == [SitesViewController class]){
                            BackupsViewController *backup = [[BackupsViewController alloc] initWithStyle:UITableViewStyleGrouped andID:cg_id];
                            [websites pushViewController:backup animated:NO];
                            [websites pushViewController:details_controller animated:YES];

websites is a navigation controller, and it is not nil.

Now the first time I run it, it works fine. But if I sign out, and sign back in it doesn't work. In fact, nothing happens. It stays on the same page it is on. I have already checked to make sure nothing is nil. I also know that I am entering into this if statement and none others.

Here is the logout function:

  AppDelegate * appDelegate = (GCAppDelegate*)[[UIApplication sharedApplication] delegate];
 [appDelegate.tabBarController setSelectedIndex:0]
UINavigationController * topViewController = appDelegate.tabBarController.viewControllers[0];
[topViewController presentViewController:loginScreen animated:YES completion:nil];
[topViewController popToRootViewControllerAnimated:TRUE];
[self deteleKeysAndTokens: (NSString*)k_apiSecret withAccessToken: (NSString*)k_accessToken withAccessSecret:(NSString*) k_accessSecret withkAPIKey: (NSString*)k_apiKey];

In case it might help, the backupViewController is downloading a list of websites, and the detailsViewcontroller is getting information about the websites. In fact, after making the call:

 [websites pushViewController:backup animated:NO];
 [websites pushViewController:details_controller    
  animated:YES];

(This is from the first bit of code I posted.) I check to see what the topViewController is:

      UIViewController * topView = websites.topViewController;

The topViewController is the details_controller. So I know it is being pushed onto the stack. However, nothing is happening. I am on the same view I started on. I was thinking that maybe it was because I hadn't gotten all the data. But that doesn't explain (a) why it works the first time through and (b) why it just doesn't display a blank page.

Was it helpful?

Solution

It's hard to say what is wrong as from code it's not clear what is the hierarchy of views.

First make sure you are using the correct navigation controller:

UINavigationController * websites = viewController.navigationController;
[websites pushViewController:anotherViewController animated:NO];

Also I'm not sure why your logout function is so complicated. Where do you execute it? Anyway, its not good to present view controller on navigation controller and then pop it to root. And also both of them are animated...

Please provide more code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top