Open maciekish opened 9 years ago
Has anyone done this successfully? I think the delegate is supposed to set the rect and view, but it's not clear to me how to determine that. In my case, I want it to keep pointing at the same view onscreen after rotation.
Got it. If the popover is presented from a bar button, it just uses the bounds and the bar button's view as its rect and view. If you're presenting a popover pointing at a view, you probably did:
[popover presentPopoverFromRect:view.frame inView:view.superview permittedArrowDirections:dir animated:YES];
Instead do this:
[popover presentPopoverFromRect:view.bounds inView:view permittedArrowDirections:dir animated:YES];
Remember the view you presented from, and give the delegate method the view's bounds and the view. I've got a singleton class that I use to coordinate popovers (dismiss the active one, etc), and I have a shortcut method on that class that looks like this:
-(WYPopoverController *)presentPopoverFromView:(UIView *)view withContent:(UIViewController *)content;
The singleton keeps track of the view it was given and handles the rotation.
It would be cool if the popover had a presentPopoverFromView
method that handled rotation automatically the same way it does for the bar button item...
How does one actually use
-popoverController:willRepositionPopoverToRect:inView:
?I tried the following without luck:
The output from this is:
However the popover origin still appears to be 0,0,0,0 after rotation.