UIWebView内部ScrollView

时间:2014-02-21 20:32:01

标签: ios uiwebview uiscrollview transformation zooming

我尝试根据UIWebView的内部UIScrollView的zoomScale将比例转换应用于某些CALayers。但是,我注意到在执行缩放时,minimumZoomScale / maximumZoomScale值会不断变化。这很奇怪,因为这不是UIScrollView单独使用时的表现。通常,UIScrollView的zoomScale在已明确设置的最小和最大缩放比例值之间波动。

这是从UIWebView内部UIScrollView

获取的日志
2014-02-21 15:19:36.335 CCCanvasSample[31484:70b] MIN SCALE 1.000000 //Zoomed all the way out
2014-02-21 15:19:36.335 CCCanvasSample[31484:70b] ZOOM SCALE 1.000000
2014-02-21 15:19:36.336 CCCanvasSample[31484:70b] MAX SCALE 7.200000
2014-02-21 15:19:41.433 CCCanvasSample[31484:70b] MIN SCALE 1.000000
2014-02-21 15:19:41.433 CCCanvasSample[31484:70b] ZOOM SCALE 3.179087
2014-02-21 15:19:41.434 CCCanvasSample[31484:70b] MAX SCALE 7.200000
2014-02-21 15:19:46.417 CCCanvasSample[31484:70b] MIN SCALE 0.314534
2014-02-21 15:19:46.418 CCCanvasSample[31484:70b] ZOOM SCALE 2.127526
2014-02-21 15:19:46.418 CCCanvasSample[31484:70b] MAX SCALE 2.264642
2014-02-21 15:19:49.555 CCCanvasSample[31484:70b] MIN SCALE 0.147830
2014-02-21 15:19:49.555 CCCanvasSample[31484:70b] ZOOM SCALE 1.064375
2014-02-21 15:19:49.556 CCCanvasSample[31484:70b] MAX SCALE 1.064375
2014-02-21 15:19:51.598 CCCanvasSample[31484:70b] MIN SCALE 0.138889
2014-02-21 15:19:51.598 CCCanvasSample[31484:70b] ZOOM SCALE 1.000000
2014-02-21 15:19:51.599 CCCanvasSample[31484:70b] MAX SCALE 1.000000 //Zoomed all the way in

这是来自常规UIScrollView的日志:

2014-02-21 15:24:10.342 CCCanvasSample[31540:70b] MIN SCALE 0.033884
2014-02-21 15:24:10.344 CCCanvasSample[31540:70b] ZOOM SCALE 0.033884
2014-02-21 15:24:10.344 CCCanvasSample[31540:70b] MAX SCALE 0.500000
2014-02-21 15:24:14.595 CCCanvasSample[31540:70b] MIN SCALE 0.033884
2014-02-21 15:24:14.596 CCCanvasSample[31540:70b] ZOOM SCALE 0.055143
2014-02-21 15:24:14.596 CCCanvasSample[31540:70b] MAX SCALE 0.500000
2014-02-21 15:24:16.440 CCCanvasSample[31540:70b] MIN SCALE 0.033884
2014-02-21 15:24:16.440 CCCanvasSample[31540:70b] ZOOM SCALE 0.355361
2014-02-21 15:24:16.441 CCCanvasSample[31540:70b] MAX SCALE 0.500000
2014-02-21 15:24:18.503 CCCanvasSample[31540:70b] MIN SCALE 0.033884
2014-02-21 15:24:18.504 CCCanvasSample[31540:70b] ZOOM SCALE 0.500000
2014-02-21 15:24:18.504 CCCanvasSample[31540:70b] MAX SCALE 0.500000

我还注意到,如果我尝试自己设置它,UIWebView将重置其UIScrollView的最小/最大缩放比例。 任何人都可以对这种行为有所了解吗?

1 个答案:

答案 0 :(得分:4)

经过努力,我能够获得UIWebView的准确缩放比例:

CGFloat accurateZoomScale = webView.scrollView.zoomscale/webView.scrollView.minimumZoomScale;

仍然不确定UIWebView如何操作其内部UIScrollView的具体细节,但希望这会节省一些时间。