【发布时间】:2012-03-26 00:16:37
【问题描述】:
我有这段代码来重新定位我的弹出框:
- (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];
}
所以现在当我旋转设备时,它会重新定位我的弹出框,但位置错误:
(来源:minus.com)
请注意红色矩形是targetButton
【问题讨论】:
-
检查是否确实调用了 didRotate。在 repositionPopOver 中,检查 targetButton 和 popoverController 是否不为零。
-
请注意您传递的“inView”参数。您的按钮是否存在于 self.view 中?
标签: objective-c ios ipad uiview uipopovercontroller