【问题标题】:UIPopover is repositioned but in the wrong placeUIPopover 被重新定位但在错误的位置
【发布时间】: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


【解决方案1】:

在旋转时,您可以尝试先关闭 popOver,然后重新创建它并根据方向显示它。 { if([YourPopUpViewControllerOBject].isPopOverVisible) { [[YourPopUpViewControllerOBject]dismissPopoverAnimated:YES]; } //根据方向显示PopOver的代码 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-19
    • 2017-06-21
    • 2013-01-23
    相关资源
    最近更新 更多