开发者

UIWebview in UIScrollview doesn't work properly

When I insert an UIWebView in a scrollView than before the page loads the uiscrollview works but once we the page load开发者_开发问答ed the scrollView doesn't work. How to solve the issue?

Thanks


[Right now the nested scroll views are possible, but in iOS SDK previous to iOS4.0 it was not supported. Please check the answered date before down-voting]

You have to read the Apple document for UIWebview, they are clearly saying,"Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled."

check this link:- http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html


I've been using successfully UIWebViews placed inside UIScrollView for a while.

You should be careful when setting the contentSize of the scroll view an the frame of the web view. In my case the frames are the same size and the contentSize is of the same height of the frame and the width a multiple of the frame's width.

Try to also put the metas bellow on the html loaded by the webview

and set the body to width:auto and optionally overflow:hidden.

Thats my setup.

good luck


try this

           imageView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
scrollView.autoresizesSubviews = YES;
 imageView.image = self.image;
 imageView.contentMode = UIViewContentModeScaleAspectFill;

 scrollView.delegate = self;
scrollView.userInteractionEnabled = YES;

scrollView.showsVerticalScrollIndicator = NO;
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.backgroundColor = [UIColor blackColor];
scrollView.contentSize = [[UIScreen mainScreen] applicationFrame].size;
 scrollView.scrollsToTop = NO;

[scrollView addSubview:imageView];
[self.view addSubview:scrollView];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜