So I have an iPhone application that utilizes a UINavigationController for setting up the views. When the application first starts, it presents the user with a UITableViewController and the user can select an item and it will push another view. Now I have it set so that my app remembers the user's last selection and automatically selects it and loads the correct view controller. The only problem is that I am experiencing a really weird glitch when I load the next view automatically..
When the view is pushed, the navigation toolbar will change so that a back button directed to the previous view is showing but it won't display the next view. It will instead keep showing the table view and I can interact with it as well. I can press the back button and it will change the toolbar back and the tableview is still shown. Then when I select an item it loads the view just fine.
Thanks for the help.
Code:
I determining whether to push the view controller based on whether it can connect to a server. I do this in a backround thread:
- (void)startingThread
{
[NSThread detachNewThreadSelector:@selector(loginThread:) toTarget:self withObject:communicator];
}
- (void)loginThread:(MowerCommunicator *)communicator
{
//If it can connect, launch thread complete.
[self performSelectorOnMainThread:@selector(loginThreadComplete:) withObject:communicator waitUntilDone:NO];
}
- (void)loginThreadComplete:(MowerCommunicator *)communicator
{
//push view controller
}
Now I have added NSLog statements to track if the view is actually "showing" and both viewWillAppear and viewDidAppear get called. I also check the delegate methods for the navigation controller and they get called as well.
I have a view that is the initial startup view and it reads from a server to determine what to display in the next table view. That gets pushed fine and when the tableview gets pushed, I hide the back button so the user can't get back to the first view without closing the app. Then the tableview looks at a variable in NSUserDefaults to determine with there is a saved index and then pushes the next view controller. That is when the glitch occurs. If I then press the back button to "go back" to the table view (this really just changes the navigation toolbar) and then I select an item from the table view, it loads the next view correctly. Also, I call the exact same methods when the user pressed an item from the table view and when the app loads the view automatically.