有没有人知道如何在 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/