I have a UIWebView
as the root view of a UINavigationController
. When a webpage finishes to load, I hide the navigation bar, and I'm looking for a way to show it back. Right now, I'm trying to do that when the user taps the status bar (this approach looks to me more complicated than what I want).
In order to accomplish this, firstly I get the scrollView of the webView:
for (id subview in mainWebView.subviews) {
if ([[subview class] isSubclassOfClass: [UIScrollView class]]) {
((UIScrollView *)subview).delegate = self;
}
}
and then I use the delegate method:
-(BOOL) scrollViewShouldScrollToTop:(UIScrollView *)scrollView {
[self.navigationController setNavigationBarHidden:NO animated:YES];
return NO;
}
I was hoping that this would work, but here is what happens:
- Page loads, and navigation bar gets hidden (that's good)
- I try to tap the status bar, but nothing happens (that's bad)
- I scroll down so that the webview is "far" from the status bar
- Without letting the webview go, I tap the status bar with another finger and it works! (that's weird :)
Soooo, any help regarding that? Why is this happening?
I had same problem. I solved it by :
Also you can get access scrollView property in iOS 5 by :
I just tried this again in iOS 5.0 and it seems to work as expected:
and then: