简体   繁体   中英

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. How can I get the exact y/x coordinates of that UIImageView at any time?

I need to know the exact x/y points on the screen, even as a user scrolls up and down within the tableview. 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.

Thanks.

I believe what you want is the UIView convertPoint view. 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 :

I ended up using CGRect rect = [infoTableView convertRect:itemImageView.frame toView:nil]; and it worked perfectly. Thanks for the help!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM