簡體   English   中英

UIScrollview中的UIWebview無法正常工作

[英]UIWebview in UIScrollview doesn't work properly

當我在scrollView中插入一個UIWebView比在頁面加載之前插入uiscrollview工作但是一旦我們加載頁面,scrollView就不起作用了。 如何解決這個問題?

謝謝

[現在可以使用嵌套滾動視圖,但在iOS4.0之前的iOS SDK中,它不受支持。 請在投票前檢查回答日期]

您必須閱讀用於UIWebview的Apple文檔,他們清楚地說,“重要的是:您不應該在UIS​​crollView對象中嵌入UIWebView或UITableView對象。如果這樣做,可能會導致意外行為,因為兩個對象的觸摸事件可能混淆並且處理不當。“

檢查此鏈接: - http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html

我已成功使用UIScrollView中的UIWebViews一段時間了。

將滾動視圖的contentSize設置為Web視圖的框架時應該小心。 在我的情況下,幀的大小相同,contentSize與幀的高度相同,寬度是幀寬度的倍數。

嘗試將metas bellow放在webview加載的html上

並將body設置為width:auto並可選擇overflow:hidden。

多數民眾贊成我的設置

祝好運

嘗試這個

           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];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM