Not understanding conversion of CGRect method


#1

CGRect rect = [self.view convertRect:cell.thumbnailView.bounds fromView:cell.thumbnailView];

Please explain this line of code. thanks


#2

That is saying “what is the frame (rectangle) of cell.thumbnailView with respect to the frame of self.view”. Does that help?


#3

Thanks make sense now. but why do you use the conversion of rect as the frame of popovercontroller, i mean the first my thumbnail’s frame with respect to self.view is only 2,2.5. But the UIPopOver doesn’t appear to have a frame with origin of 2,2.5

An example would be the Homepwner project we’re woking on using the book
if you look at this pic the top left edges of UIPopover is on the Navigation Controller above self.view.


#4

chanyeechoong, in the simulator create multiple items and tap any thumbnail image except the one of the first row item. You’ll notice what the conversion does in your code.

As documented, that method also specifies the location at which the arrow appears and through our conversion we determine the anchor point dynamically according to the cell item’s location in the view.


#5

How can you explain the first thumbnail then?


#6

UIPopoverControllers get presented above everything, which explains why it is over the navigation bar. The conversion only dictates where the arrow should point at, and you can see in your screen shot that the arrow is pointing at the thumbnail appropriately.