久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

縮放圖像以適應 iPhone 旋轉時的屏幕

Scale image to fit screen on iPhone rotation(縮放圖像以適應 iPhone 旋轉時的屏幕)
本文介紹了縮放圖像以適應 iPhone 旋轉時的屏幕的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個包含 UIImageView 的 UIScrollView,但當 iPhone 旋轉時我很難獲得正確的行為.

I have a UIScrollView containing an UIImageView and I have some trouble to get the correct behavior when the iPhone rotates.

目標:從縱向到橫向時,我試圖獲得以下內容:

Goal: I am trying to obtain the following when going from portrait to landscape:

_________
|AAAAAAA|
|BBBBBBB|         _________________
|CCCCCCC|         |     AAAAAA     |
|DDDDDDD|    -->  |     CCCCCC     |
|EEEEEEE|         |     EEEEEE     |
|FFFFFFF|         |_____GGGGGG_____|
|GGGGGGG|
---------

當 iPhone 旋轉時,縱向視圖中的整個圖像被縮放以適應橫向視圖.它也是居中的.我也試圖保持縱橫比.用戶交互也已開啟,用戶應該能夠使用整個屏幕來平移/縮放圖像.

Here the entire image in the portrait view is scaled to fit in the landscape view when the iPhone rotates. It is also centered. I am also trying to preserve the aspect ratio. User interaction is also on, and the user should be able to use the entire screen to pan/zoom the image.

目前我在滾動視圖上有以下 autoresizingMask:

Currently I have the following autoresizingMask on the scrollView:

 scrollView.autoresizingMask =(UIViewAutoresizingFlexibleWidth |
                               UIViewAutoresizingFlexibleHeight);       

但這給出了以下內容

_________
|AAAAAAA|
|BBBBBBB|         _________________
|CCCCCCC|         |AAAAAA          |
|DDDDDDD|    -->  [BBBBBB          |
|EEEEEEE|         [CCCCCC          |
|FFFFFFF|         [DDDDDD__________|
|GGGGGGG|
---------

此設置保留從左上角的比例和偏移.

This setting preserves scale and offset from upper left corner.

問題:是否可以使用合適的 autoresizingMask 獲得這種行為?如果沒有,可能應該設置

Question: Is it possible to obtain this behaviour using suitable autoresizingMask? If not, one should probably set

 scrollView.autoresizingMask = UIViewAutoresizingNone;

并在旋轉時為 UIScrollView 手動設置 zoomScalecontentOffset.但是,應該在哪里做呢?為這種變化設置動畫怎么樣?

and manually set zoomScale and contentOffset for the UIScrollView on rotation. But, where should that be done? What about animating that change?

解決方案:通過稍微修改下面的答案,我得到了上述行為以下代碼:

Solution: By very slightly modifying the answer below I got the above behaviour using the below code:

imageView.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
                                     UIViewAutoresizingFlexibleHeight);

scrollView.autoresizingMask =(UIViewAutoresizingFlexibleWidth 
                                     | UIViewAutoresizingFlexibleHeight);

imageView.contentMode = UIViewContentModeScaleAspectFit;
scrollView.contentMode = UIViewContentModeCenter;

推薦答案

試試這個:

scrollView.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
                           UIViewAutoresizingFlexibleHeight);    
imageView.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
                           UIViewAutoresizingFlexibleHeight);

imageView.contentMode = UIViewContentModeAspectFit; // You could also try UIViewContentModeCenter

我不確定 imageView 是否會在 UIScrollView 中自動調整大小,所以如果自動調整大小不起作用,您可以嘗試自己設置框架旋轉以等于滾動視圖的大小.

I'm not sure if the imageView will get automatically resized within a UIScrollView, so if the autoresizing doesn't work, you could try setting the frame yourself on rotate to equal the size of the scrollview.

這篇關于縮放圖像以適應 iPhone 旋轉時的屏幕的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

how to set scrollview content size in swift 3.0(如何在 swift 3.0 中設置滾動視圖內容大小)
Stop a UITableView from automatically scrolling(阻止 UITableView 自動滾動)
iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
using iOS 6.0 SDK and building for iOS 5 Target causes UIScrollView setMinimumZoomScale to fail when running on iOS 5 simulator(在 iOS 5 模擬器上運行時,使用 iOS 6.0 SDK 并為 iOS 5 Target 構建會導致 UIScrollView setMinimumZ
Create partial-screen UIPageViewController programmatically(以編程方式創建部分屏幕 UIPageViewController)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
主站蜘蛛池模板: 久久综合久久综合久久综合 | 一级片子 | 福利网址 | 欧美日韩不卡合集视频 | 成人av一区 | 亚洲顶级毛片 | 精品国产乱码久久久久久久久 | 国产婷婷色综合av蜜臀av | 91最新视频 | 国产美女福利在线观看 | 国产福利91精品一区二区三区 | 2018天天干天天操 | 国产欧美精品一区二区色综合 | 一级特黄色毛片 | 99视频免费在线观看 | www.午夜| 91精品久久久久 | 欧美日韩精品在线免费观看 | 日日爽| 久久国产传媒 | 国产精品一区二区福利视频 | 精品麻豆剧传媒av国产九九九 | 成人精品国产一区二区4080 | 怡红院成人在线视频 | 欧美影院| 亚洲视频免费观看 | 男人的天堂在线视频 | 91在线影院| 国产玖玖| 日韩电影免费在线观看中文字幕 | 国产一区二区成人 | 91亚洲国产 | 男人天堂99 | 国产精品久久久久久久免费大片 | 黑人精品xxx一区一二区 | 欧美日韩国产精品激情在线播放 | 亚洲一区视频在线播放 | 99亚洲精品 | 美女日批免费视频 | 成人久久视频 | 粉嫩av久久一区二区三区 |