UINavigationController back button problem
HEllo,
I have a hybrid iPhone application that has a UITabBarController and 5 Tabs. Each tab hosts a UINavigationViewController initialized with a root controller that is a UIViewController hosting one UIWebView. On a certain specific link, I push a UITableViewController inherent on the navigation Cont开发者_如何转开发roller (which shows some data stored locally) and has a back button. Following is the code after i parse the URL string in shouldStartLoadWithRequest: method.
UINavigationController *navControl = (UINavigationController *)self.parentViewController;
CartTableViewController *tabView = [[CartTableViewController alloc] init];
[navControl pushViewController:tabView animated:YES];
navControl.navigationBar.hidden = NO;
return YES;
This works fine. The specific link is parsed and the table view is pushed onto the navigationStack. When i click the back button though (and yes it shows 'back' rather than previous view's name which is, say 'news') i get another table view but this time the back button is named 'news'. and when i click on that, i go back to my rootcontroller. I don't seem to find from where are two views pushed onto the stack over root view.
Thanks. Zaki
Your implementation of webView:shouldStartLoadWithRequest:navigationType is probably being called twice. One solution would be to only create and push an instance of CartTableViewController if an instance isn't already on the UINavigationController stack.
if (![navControl.topViewController isKindOfClass:[CartTableViewController class]]) {
CartTableViewController *tabView = [[[CartTableViewController alloc] init] autorelease];
[navControl pushViewController:tabView animated:YES];
navControl.navigationBar.hidden = NO;
}
You should also be releasing your tabView instance too.
Okay i found the issue. I need to return NO from shouldStartLoadWithRequest: for such a thing. Sorry for the bother
精彩评论