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

后端 未结 9 1020
执笔经年
执笔经年 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:08

    I had a similar problem after playing a Youtube video within my app. scrollsToTop was still set to YES but tapping the status bar had no effect.

    I finally realised that my app window was no longer the key window. After adding the following line to a UIWindow subclass (which I already had for other reasons) everything worked as it should again:

    if (![self isKeyWindow]) [self makeKeyWindow];
    
    0 讨论(0)
  • 2020-12-05 13:12

    I was having a similar problem where the scroll-to-top functionality was lost. Turns out this will only work when you have only one active view at a time (within the same scroll view). In my case I had a table view and another view which would fade in/out. Adding a removeFromSuperview at the end of the animation did the trick.

    The answer was in the UIScrollView.h file comments:

    /*
     this is for the scroll to top gesture. by default, a single scroll visible scroll view with this flag set will get the call. if there is more than one visible with this
     flag set or the delegeat method returns NO, the view isn't scrolled 
     */
    @property(nonatomic) BOOL  scrollsToTop;          // default is YES. if set, special gesture will scroll to top of view after consulting delegate
    
    0 讨论(0)
  • 2020-12-05 13:13

    You can use the following code to have the UIWebView ignore scrollToTop without the extra UIScrollView:

    ((UIScrollView *)[[webView valueForKey:@"_internal"] valueForKey:@"scroller"]).scrollsToTop = NO;
    
    0 讨论(0)
提交回复
热议问题