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

如何在 UIScrollView 中啟用縮放

How to enable zoom in UIScrollView(如何在 UIScrollView 中啟用縮放)
本文介紹了如何在 UIScrollView 中啟用縮放的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如何在 UIScrollView 中啟用縮放功能?

How do I enable zooming in a UIScrollView?

推薦答案

答案是 這里:

滾動視圖還可以處理內容的縮放和平移.當用戶做出捏合或張開手勢時,滾動視圖會調整內容的偏移量和比例.當手勢結束時,管理內容視圖的對象應根據需要更新內容的子視圖.(請注意,手勢可以結束并且手指仍可能向下.)在手勢進行期間,滾動視圖不會向子視圖發送任何跟蹤調用.

A scroll view also handles zooming and panning of content. As the user makes a pinch-in or pinch-out gesture, the scroll view adjusts the offset and the scale of the content. When the gesture ends, the object managing the content view should update subviews of the content as necessary. (Note that the gesture can end and a finger could still be down.) While the gesture is in progress, the scroll view does not send any tracking calls to the subview.

UIScrollView 類可以有一個必須采用 UIScrollViewDelegate 協議的委托.要使縮放和平移工作,代理必須同時實現 viewForZoomingInScrollView: 和 scrollViewDidEndZooming:withView:atScale:;另外,最大(maximumZoomScale)和最小(minimumZoomScale)縮放比例必須不同.

The UIScrollView class can have a delegate that must adopt the UIScrollViewDelegate protocol. For zooming and panning to work, the delegate must implement both viewForZoomingInScrollView: and scrollViewDidEndZooming:withView:atScale:; in addition, the maximum (maximumZoomScale) and minimum (minimumZoomScale) zoom scale must be different.

所以:

  1. 您需要一個實現 UIScrollViewDelegate 并在您的 UIScrollView 實例上設置為 delegate 的委托
  2. 在您的委托上,您必須實現一種方法:viewForZoomingInScrollView:(必須返回您對縮放感興趣的內容視圖).您還可以選擇實現 scrollViewDidEndZooming:withView:atScale:.
  3. 在您的 UIScrollView 實例上,您必須將 minimumZoomScalemaximumZoomScale 設置為不同(默認為 1.0).
  1. You need a delegate that implements UIScrollViewDelegate and is set to delegate on your UIScrollView instance
  2. On your delegate you have to implement one method: viewForZoomingInScrollView: (which must return the content view you're interested in zooming). You can also implement scrollViewDidEndZooming:withView:atScale: optionally.
  3. On your UIScrollView instance, you have to set the minimumZoomScale and the maximumZoomScale to be different (they are 1.0 by default).

注意:有趣的是,如果您想打破縮放.viewForZooming... 方法中返回 nil 是否足夠?它確實打破了縮放,但一些手勢會被弄亂(兩根手指).因此,要中斷縮放,您應該將最小和最大縮放比例設置為 1.0.

Note: The interesting thing about this is what if you want to break zooming. Is it enough to return nil in the viewForZooming... method? It does break zooming, but some of the gestures will be messed up (for two fingers). Therefore, to break zooming you should set the min and max zoom scale to 1.0.

這篇關于如何在 UIScrollView 中啟用縮放的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

How to subclass UIScrollView and make the delegate property private(如何繼承 UIScrollView 并使委托屬性私有)
Swift - how to get last taken 3 photos from photo library?(Swift - 如何從照片庫中獲取最后拍攝的 3 張照片?)
Setting contentOffset programmatically triggers scrollViewDidScroll(以編程方式設置 contentOffset 觸發 scrollViewDidScroll)
Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中頁面之間的照片應用程序式間隙)
why UIScrollView is leaving space from top in ios 6 and ios 7(為什么 UIScrollView 在 ios 6 和 ios 7 中從頂部留下空間)
UIScrollView pauses NSTimer while scrolling(UIScrollView 在滾動時暫停 NSTimer)
主站蜘蛛池模板: 18av在线播放| 欧美成人h版在线观看 | 欧美日日| 亚洲视频免费观看 | 日韩欧美国产成人一区二区 | 久久久久久久av麻豆果冻 | 日日夜夜天天综合 | 亚洲久久一区 | 欧美日韩免费在线 | 精品91久久 | 国产精品区一区二区三区 | 欧美男人天堂 | 成人精品一区二区三区 | 亚洲欧美成人 | 99精彩视频 | 午夜影视免费片在线观看 | 亚洲 欧美 精品 | 久久亚洲精品久久国产一区二区 | 日韩一区二区在线视频 | 国产精品一区一区三区 | 国产区精品| www.一区二区 | 国产日韩亚洲欧美 | 国产成人一区二区三区精 | 日韩免费一二三区 | 日韩欧美高清dvd碟片 | 国产一二三区精品视频 | 国产性网| 亚洲国产精品99久久久久久久久 | 成人欧美一区二区三区色青冈 | a a毛片| 日韩精品久久久久 | 亚洲国产成人精品女人久久久 | 亚洲啊v在线 | 色资源站 | 新超碰97| 中文在线一区二区 | 欧美日韩中文字幕在线播放 | 久久亚洲欧美日韩精品专区 | 国产一区二区三区在线免费观看 | 精品久久久久一区二区国产 |