phi
phi

Reputation: 10733

Status bar detects taps only when the UIWebView is scrolled down a bit

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:

Soooo, any help regarding that? Why is this happening?

Upvotes: 1

Views: 1286

Answers (2)

phi
phi

Reputation: 10733

I just tried this again in iOS 5.0 and it seems to work as expected:

[self.webView.scrollView setDelegate:self];
[self.webView.scrollView setScrollsToTop:YES];

and then:

-(void)scrollViewDidScrollToTop:(UIScrollView *)scrollView
{
    [self.navigationController setNavigationBarHidden:NO animated:NO];
}

Upvotes: 1

Maulik
Maulik

Reputation: 19418

I had same problem. I solved it by :

[[[webView subviews] objectAtIndex:0] setScrollsToTop:NO];

Also you can get access scrollView property in iOS 5 by :

webView.scrollView.scrollsToTop = NO ;

Upvotes: 0

Related Questions