In my iOS app I have to have some native code and some web code. I am having a little difficulty integrating the navigation of the two.
For iOS I am using an embedded UINavigationController. In the web app I am using a single page application control with the Application Page doing the navigation through the web pages.
Here is the problem. On the first web page I suppress the navigation, as I want to use the iOS navigation there (to go back to from the main menu). A user taps the a list entry and the 2nd web page appears. Here I want to do the opposite - suppress the iOS Navigation but show the web navigation.
So I use the method shouldStartLoadingWithRequest to control whether or not to show the native UINavigation Controller. [method below]
- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType {
NSURL *url = request.URL;
NSString *urlString = [url absoluteString];
if ([urlString
isEqual:
@"https://myURL.xsp"] ||
[urlString isEqual:@"https://myURL.xsp/"]) {
[self.navigationController setNavigationBarHidden:FALSE animated:YES];
} else {
[self.navigationController setNavigationBarHidden:TRUE animated:YES];
}
return YES;
}
My problem is that when a user taps the web navigation to go back to the first view, the event does not fire again (as I am in the uiWebView I assume and so nothing in iOS has changed) and so I lose the native navigation. What I think I need is a way to fire off this method if the uiView changes?
Or is there a better way to handle this?