我有这个代码来重新定位我的popover:
- (void)repositionPopOver {
if (self.targetButton) {
[self.popoverController presentPopoverFromRect:self.targetButton.frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
// Reposition the Popover after rotation
[self repositionPopOver];
}
所以现在当我旋转设备时,它会重新定位我的弹出窗口,但是在错误的位置:
http://i.minus.com/jbxYSIHSJhV8yC.png
请注意,红色矩形是targetButton
答案 0 :(得分:0)
旋转时,您可以先尝试解除popOver,然后重新创建并根据方向显示它。 { 如果([YourPopUpViewControllerOBject] .isPopOverVisible) { [[YourPopUpViewControllerOBject] dismissPopoverAnimated:YES]; } //基于方向显示PopOver的代码 }