How can I enable zoom in on UIWebView which inside the UIScrollView?

前端 未结 4 1366
你的背包
你的背包 2020-12-04 10:21

I have a UIWebView which inside a UIScrollView (scrollview contain another component)

I tried to enable multitouch both on Interfac

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 11:05

    OK, you need to do both the above, but also the following. I had a web view in the main view, and that didn't work.

    1. As above, you first have to put a UIScrollView in the main view, then put the web view in the scroll view.
    2. As above, implement in your view controller, drag the scroll view delegate to the view controller in Interface Builder, and implement the viewForZoomingInScrollView method. This must return the pointer to the UIScrollView (return myScrollView).
    3. I created IBOutlet properties for both the web view and the scroll view - link them in the NIB to your view controller.
    4. On the Scroll View, go to the Attributes Inspector, set your Max and Min zoom factors (I set 0.5 to 5.0, that works well).
    5. On the Web View, in the Attributes Inspector:
    6. In the Web View section, select Scales Pages To Fit
    7. In the View section, select for Mode, "Top Left"
    8. In the View section at the bottom, check off User Interaction Enabled, and Multiple Touch Enabled

提交回复
热议问题