![](/img/trans.png)
[英]How can I get an X and Y coordinate, based on a user's touch on an image, that will be the same on any device
[英]How can I find the x coordinate of the contentView that is equal to the center x of a UIScrollView's frame
我有一個UIScrollView
可以水平滾動。 我有大約10個視圖在該滾動視圖中水平排列。 我想找到一個包含滾動視圖框架的中心點(而不是contentView.frame)的視圖。 我正在考慮使用- (void)scrollViewDidScroll:(UIScrollView *)scrollView
UIScrollView
委托方法,但是我不確定如何找到它。
謝謝!
您可以使用以下代碼在另一個視圖( scrollView
)的引用中獲取視圖框架( myChildView
)的scrollView
:
CGPoint origin = [myChildView convertPoint:CGPointMake(myChildView.bounds.origin.x, myChildView.bounds.origin.y) toView:[self scrollView]];
使用scrollViewDidScroll:
委托方法來選擇您的視圖並在那里執行計算。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.