Converting a CGRect of a object in a subview in UITableViewCell in UITable to CGRect with respect to self.view

荒凉一梦 提交于 2019-12-06 18:24:53

问题


I want to convert a CGRect "aRect" of a object in a subview in UITableViewCell in UITableView to CGRect with respect to self.view.

The problem is that aRect is with respect to the subview in the table cell. But i want to make it so that it is with respect to self.view.

What i tried is this

rect = [self.view convertRect:aRect.frame toView:cellView];

but it doesn't work.

So how to convert it?


回答1:


Since convertRect:toView: actually deals with a CGRect in the receiver’s coordinate system, maybe [cellView convertRect:theFrame toView:self.view] (i.e. swapping the two views in your call) will work as you intended.



来源:https://stackoverflow.com/questions/3010594/converting-a-cgrect-of-a-object-in-a-subview-in-uitableviewcell-in-uitable-to-cg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!