2014-02-21 157 views
1

我想將一個縮放轉換應用到一些基於UIWebView的內部UIScrollView的zoomScale的CALayers。但是,我注意到最小縮放比例/最大縮放縮放值隨着縮放的執行而不斷變化。這很好奇,因爲這不是UIScrollView單獨使用時的表現。通常,UIScrollView的zoomScale在顯式設置的最小和最大縮放比例值之間波動。UIWebView內部滾動查看

下面是從一個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縮放比例。 任何人都可以闡明這種行爲?

回答

4

與此掙扎了一會兒後,我能得到一個UIWebView準確的變焦倍數:

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

還是不確定的UIWebView中如何操縱其內部的UIScrollView的具體細節,但希望這會節約一些時間。