问题
I am using a scrollView, in which i have added some static content in a container view and below this container view i have added a web view and added both these views into my scrollView, I dont want the web view to be scroll, instead I want that my scrollview should scroll according to the height of my container view and height of contents in web view.
Note: I am loading contents in webview as html string, that i am receiving from server, The contents are coming in between of html tags and i am then passing this as a string to web view.
Thanks
回答1:
try this code
CGRect contentRect = CGRectZero;
for (UIView *subview in scrollview.subviews ) {
contentRect = CGRectUnion(contentRect,subview.frame);
}
scrollview.contentSize = CGSizeMake(scrollview.bounds.size.width, CGRectGetMaxY(contentRect));
回答2:
set scrollview Content Size as containerview height + webview height
and your webview Height must be equal to the content Size of that Webview because you don't want to scroll your webview.
回答3:
- find height of contents in webview
- make it the size of webview,containerview frame and scrollview contentsize
- disable scroll of webview
来源:https://stackoverflow.com/questions/17042004/uiscrollview-subviews-contents-size-issue