ios6 - 如何在 iOS 6 方向更改之前关闭弹出窗口?

标签 ios6 orientation popover dismiss

有没有人知道如何在 iOS 6 上方向改变时关闭弹出窗口。 我尝试了以下方法:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

    if ([self.popoverController isPopoverVisible]) {
        [self.popoverController dismissPopoverAnimated:NO];
    }
}

但它对我不起作用。旋转后弹出窗口仍然存在。

- (BOOL) shouldAutoRotate

未在我的 viewController 中调用,因为它位于 SplitViewController 和 NavController 中。 我读过我可以从这个容器中继承以转发 shouldAutorotate,但由于不同的原因我不想这样做。 我不想在 orientationchange 之后关闭 popover(在 didRotateFrom...),因为它很丑。

你有什么想法吗,我怎样才能在 iOS 6 上改变方向之前关闭弹出窗口?

最佳答案

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(deviceOrientationDidChange:)
                                             name:UIDeviceOrientationDidChangeNotification
                                           object:nil];

这将在旋转确实改变后执行,然后您可以在设备方向上执行您想要的操作。否则,您需要监听 View Controller 并将消息发送到那里。

关于ios6 - 如何在 iOS 6 方向更改之前关闭弹出窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13375275/

相关文章:

windows - Windows 上的 Safari 远程调试

ruby-on-rails - Twitter Bootstrap 弹出框不工作

ios - 我如何创建一个将在 iPad 上使用弹出窗口的 segue,并推送到 iPhone 上的导航堆栈?

android - java.lang.IllegalArgumentException : View not attached to window manager 异常

ios - shouldAutorotateToInterfaceOrientation 在 UIImagePickercontroller 之后禁用

javascript - 无法从 Angularjs 组件访问 Popover 模板上的变量

ios - UICollectionView:-[UICollectionView _endItemAnimations] 中的断言失败

objective-c - 如何在 Core image 中通过 CIFilter 更改最小值或最大值?

ios - 支持多种iOS-应用开发

javascript - 隐藏 safari ios 上的方向转换