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

獲取 UIScrollView 內(nèi)容的可見矩形

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

問題描述

如何找出屏幕上實(shí)際可見的顯示視圖內(nèi)容的矩形 (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

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

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

為了澄清,我想要一個(gè)包含滾動(dòng)視圖內(nèi)容的可見區(qū)域的 CGRect,相對(duì)于內(nèi)容.(即,如果它是縮放比例 2,矩形的大小將是滾動(dòng)視圖大小的一半,如果它是縮放比例 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 的回答,這并沒有完全解決問題,但給了我回答的基礎(chǔ):

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;

主要區(qū)別在于 visibleRect 的大小應(yīng)該是 scrollView.bounds.size,而不是 scrollView.contentSize 是內(nèi)容視圖的大小.還稍微簡化了數(shù)學(xué),并沒有完全看到 isless() 的用途,它會(huì)在代碼更大時(shí)破壞代碼.

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.

這篇關(guān)于獲取 UIScrollView 內(nèi)容的可見矩形的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

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(以編程方式設(shè)置 contentOffset 觸發(fā) scrollViewDidScroll)
Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中頁面之間的照片應(yīng)用程序式間隙)
why UIScrollView is leaving space from top in ios 6 and ios 7(為什么 UIScrollView 在 ios 6 和 ios 7 中從頂部留下空間)
UIScrollView pauses NSTimer while scrolling(UIScrollView 在滾動(dòng)時(shí)暫停 NSTimer)
主站蜘蛛池模板: 亚洲一区二区综合 | 午夜精品久久久久久久久久久久 | 亚洲在线免费观看 | 日韩三级电影在线看 | 91久久| 一本大道久久a久久精二百 国产成人免费在线 | 久久91 | 先锋资源网 | 久久久成人精品 | 在线看av网址| 亚洲欧美成人 | 国产成人免费视频网站视频社区 | 美国av片在线观看 | 精品亚洲一区二区 | 免费午夜视频 | 国产精品日韩一区二区 | 91看片网址 | 欧美一级片免费看 | 中文字幕乱码亚洲精品一区 | 欧美在线一区二区三区 | 久久久久久久久久久久久9999 | 美人の美乳で授乳プレイ | 在线亚洲人成电影网站色www | 97久久精品 | 亚洲精品乱 | 免费a网站 | 欧美日韩综合视频 | 精品视频一区二区三区在线观看 | 成人av播放 | 欧美日韩高清一区二区三区 | 在线观看www视频 | 久久九精品 | 久热精品在线播放 | www.亚洲.com| 成人小视频在线免费观看 | 午夜免费观看体验区 | 久久久久久91 | 国产黑丝av | 久久久久久久久久影视 | 一级毛片视频 | 国产精品久久久久久久久久软件 |