I have a nav based app. Once a row is clicked in a tableview, I push a UIWebView. The UIWebView has web links in it. The user clicks a link, which renders the external webpage. This all happens within my app. The top nav bar hasn't changed with the clicking of a link that renders and external webpage. However, once the user clicks the top left nav button, they go back to the tableview rather than the initial UIWebView. How can I wire up to the nav back button and put the user back to the initial UIWebView if they are clicking from following an external link?
+2
A:
You can be notified of navigation controller changes, but I don't believe you can prevent them from happening (UINavigationControllerDelegate protocol).
One way to solve this is to set up an object to be the webview's delegate (UIWebViewDelegate protocol) and implement:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
Here return NO to avoid opening the link in the webview, hand the request over to a webview in a second view controller, and push this second view controller on the navigation controller stack.
This way you don't have to intercept the backwards navigation but the UI behaves like the user expects.
duncanwilcox
2009-04-19 09:33:52