views:

190

answers:

1

Hey, I want to converte a CGRect "aRect" of a object in a subview in UITableViewCell in UITable 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  A: 

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.

Evadne Wu
Or use the fromView variant.
drawnonward
thx evadne.By the way drawnonward, what is the difference between toView variant and fromView variant?
David Gao
Calling the `toView` variant means that the rect is in the view’s coordinate system and we want to know its equivalent in the other view’s coordinate system. Calling the `fromView` variant means that we want to know where a rect residing in the other view will be placed in the receiver view.
Evadne Wu
thx evadne, ur explanation was super helpful!
David Gao