iPhone OS: Tap status bar to scroll to top doesn't work after remove/add back

后端 未结 9 1049
执笔经年
执笔经年 2020-12-05 12:30

Using this method to hide the status bar:

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];

When setting \"hidden\"

9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-05 13:07

    The following fix by Alex worked for me. Thanks!

    ((UIScrollView *)[[webView subviews] objectAtIndex:0]).scrollsToTop = NO;
    

    Being in a hurry this fix worked great, however given more time I might've subclassed the UIWebView and accessed the protected UIScrollView member directly.

    The worry I have with Alex' method is that it assumes that UIScrollView is at index zero of the subviews (encapsulation allows private members to change). Which suggests another solution still:

    for (UIView* v in [webView subviews])
    {
        if ([v isKindOfClass:[UIScrollView class]])
        {
            (UIScrollView *)v.scrollsToTop = NO;
        }
    }
    

提交回复
热议问题