久久久久久久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)
主站蜘蛛池模板: 免费日韩av网站 | 国产在线精品一区 | 欧美性猛交一区二区三区精品 | 久久99精品久久久久久 | www.99re5.com| 欧美精品在线一区二区三区 | 自拍偷拍中文字幕 | 中文字幕av在线一二三区 | 欧美日韩中文字幕在线 | 久久久av一区 | 中文字幕成人在线 | 久久精品无码一区二区三区 | 亚洲综合99| 亚洲免费一区二区 | 精品精品 | 国产日产精品一区二区三区四区 | 国产精品99久久久久久动医院 | 综合久久99 | 国产高清精品在线 | 色爱区综合 | 日本成人中文字幕 | 在线观看国产视频 | 久久亚洲春色中文字幕久久久 | 一区二区三区国产好的精 | 男女一区二区三区 | 最新午夜综合福利视频 | 久久久.com | 九九热这里只有精品6 | 国外成人在线视频 | 在线播放中文字幕 | 中文字幕在线视频网站 | 国产人久久人人人人爽 | 熟女毛片 | 日本a v在线播放 | 欧美日韩高清在线一区 | 中文字幕一区在线观看视频 | 逼逼网 | 欧美日韩高清免费 | 国产精品免费看 | 国产情侣啪啪 | 一区二区免费高清视频 |