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

獲取 UIScrollView 內容的可見矩形

Getting the visible rect of an UIScrollView#39;s content(獲取 UIScrollView 內容的可見矩形)
本文介紹了獲取 UIScrollView 內容的可見矩形的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如何找出屏幕上實際可見的顯示視圖內容的矩形 (CGRect).

How can I go about finding out the rect (CGRect) of the content of a displayed view that is actually visible on screen.

myScrollView.bounds

上面的代碼在沒有縮放時有效,但是一旦你允許縮放,它會在縮放比例不是 1 時中斷.

The code above works when there's no zooming, but as soon as you allow zooming, it breaks at zoom scales other than 1.

為了澄清,我想要一個包含滾動視圖內容的可見區域的 CGRect,相對于內容.(即,如果它是縮放比例 2,矩形的大小將是滾動視圖大小的一半,如果它是縮放比例 0.5,它將是兩倍.)

To clarify, I want a CGRect that contains the visible area of the scroll view's content, relative to the content. (ie. if it's a zoom scale 2, the rect's size will be half of the scroll view's size, if it's at zoom scale 0.5, it'll be double.)

推薦答案

回答我自己的問題,主要感謝 Jim Dovey 的回答,這并沒有完全解決問題,但給了我回答的基礎:

Answering my own question, mostly thanks to Jim Dovey's answer, which didn't quite do the trick, but gave me the base for my answer:

CGRect visibleRect;
visibleRect.origin = scrollView.contentOffset;
visibleRect.size = scrollView.bounds.size;

float theScale = 1.0 / scale;
visibleRect.origin.x *= theScale;
visibleRect.origin.y *= theScale;
visibleRect.size.width *= theScale;
visibleRect.size.height *= theScale;

主要區別在于 visibleRect 的大小應該是 scrollView.bounds.size,而不是 scrollView.contentSize 是內容視圖的大小.還稍微簡化了數學,并沒有完全看到 isless() 的用途,它會在代碼更大時破壞代碼.

The main difference is that the size of the visibleRect ought to be scrollView.bounds.size, rather than scrollView.contentSize which is the size of the content view. Also simplified the math a bit, and didn't quite see the use for the isless() which would break the code whenever it's greater.

這篇關于獲取 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)
主站蜘蛛池模板: 九色 在线 | 欧美视频一级 | 91精产国品一二三区 | 日本成年免费网站 | 久久国产精品-国产精品 | 色婷婷在线视频 | 一区二区三区四区电影视频在线观看 | 久久久精品日本 | 久久99久久98精品免观看软件 | 国产精品区二区三区日本 | 日韩在线免费 | 日本综合在线观看 | 狠狠做六月爱婷婷综合aⅴ 国产精品视频网 | 国产一区二区三区在线 | 日韩欧美一区二区三区免费观看 | 精品二区 | 亚洲狠狠 | 日韩免费在线 | 午夜在线视频 | 国产一区二区精品在线观看 | 91偷拍精品一区二区三区 | 亚洲精品视频在线看 | 日韩欧美精品一区 | 狠狠干夜夜草 | 国户精品久久久久久久久久久不卡 | 亚洲成网站| 国产福利在线播放麻豆 | 国产免费一区 | 天天操夜夜爽 | 欧产日产国产精品99 | 欧美精品免费观看二区 | 中文在线一区二区 | 九九伦理片| 国产东北一级毛片 | 中文字幕日本一区二区 | 日韩中文字幕在线播放 | 久国产| 玖玖综合网| 国产高清一区二区 | 精品欧美一区二区三区免费观看 | 毛片免费观看 |