[英]I have a UIImageView in a UITableView Header. How can I get the exact y/x coordinates of that UIImageView at any time?
I have a UIImageView in a UITableView Header. 我在UITableView标头中有一个UIImageView。 How can I get the exact y/x coordinates of that UIImageView at any time? 如何随时获取该UIImageView的确切y / x坐标?
I need to know the exact x/y points on the screen, even as a user scrolls up and down within the tableview. 我需要知道屏幕上确切的x / y点,即使用户在表视图中上下滚动时也是如此。 If this is possible, can someone point me to some sample code? 如果可能的话,有人可以给我指出一些示例代码吗?
Just calling this does not work: 只是调用它不起作用:
itemImageView.frame.origin.x, itemImageView.frame.origin.y
It just gives me the coordinates as they relate to the tableView itself, regardless of it's actual position on the window. 它只是为我提供了与tableView本身相关的坐标,无论它在窗口上的实际位置如何。
Thanks. 谢谢。
I believe what you want is the UIView convertPoint view. 我相信您想要的是UIView convertPoint视图。 You can convert the point you get to the table view's space. 您可以将获得的点转换为表格视图的空间。
http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instm/UIView/convertPoint:toView : http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instm/UIView/convertPoint:toView :
I ended up using CGRect rect = [infoTableView convertRect:itemImageView.frame toView:nil];
我最终使用了CGRect rect = [infoTableView convertRect:itemImageView.frame toView:nil];
and it worked perfectly. 而且效果很好。 Thanks for the help! 谢谢您的帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.