uiwebview within uiscrollview

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 04:25:01

问题


I am having an issue with a uiwebview within a scrollview. In this scrollview, there is a "header" view at top and "bottomview" which is the webview. I am loading the data into the webview using loadHTMLstring method. What I am trying to do is that when I zoom, it should zoom in only on the bottom portion, not the top part. This is very similiar to the native email app on the iphone. I have been at this for 2 days now with no luck. Any help would be appreciated. thanks in advance.


回答1:


In short : your scrollViewDelegate must implement viewForZoomingInScrollView and return the webView.

In details :

Set your scrollViewController as the delegate of the scrollView:

myScrollView.delegate = yourScrollViewController;

In YourScrollViewControllerClass.h :

@interface YourScrollViewControllerClass <UIScrollViewDelegate> {
    [...]
}

In YourScrollViewControllerClass.m implement viewForZoomingInScrollView to tell which view must be zoomed when a zoom is asked :

-(UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollViewBis {
    return yourWebView; 
}


来源:https://stackoverflow.com/questions/2959533/uiwebview-within-uiscrollview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!