iphone: View on top of UIWebView?

前端 未结 4 1180
-上瘾入骨i
-上瘾入骨i 2021-02-04 15:35

I\'m working on a browser app, and I have an address bar on top the UIWebView. On MobileSafari if you scroll down, the address bar starts to move to the top, out of the screen,

4条回答
  •  名媛妹妹
    2021-02-04 16:27

    Come to think of it, it is simply a scrolling view with an address bar stuck on the top, and both the web view and the bar always move together. Now, lets say you create a scroll view and add two subviews, the address bar and the web view (one below the other). It is to be noted that the height of the web view is determined and fixed after the page has been loaded (in webViewDidFinishLoad:).

    Hence, it is simply a scrolling view whose contentSize is equal to the height of the bar + the height of the web view. Now, by default the web view allows scrolling, as it has a scroll view as a subview. As only the outer scroll view should be scrolling, it is required that the web view's scrolling be turned off. For that, fetch the first subview (that's the scroll view) and disable its scrolling using:

    (UIScrollView*)[myWebView.subviews objectAtIndex:0].scrollEnabled = NO;
    

提交回复
热议问题