【发布时间】:2015-07-28 20:52:45
【问题描述】:
我正在更新一个已有 5 年历史的应用程序(最初是为 iOS 3 编写的!)。我在使用自动布局和解决弃用警告方面取得了不错的进展。但是用于在设备旋转时呈现不同视图控制器的旧技术不再可靠。
- (void)orientationChanged:(NSNotification *)notification {
UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
if (deviceOrientation == UIInterfaceOrientationLandscapeRight && !showingOtherVC) {
// switch to other VC
othervc.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:othervc animated:YES completion:nil];
[self resignFirstResponder];
}
另一个视图控制器确实出现了,但它是横向布局的,用于纵向屏幕,而不是横向屏幕,即使设备处于横向。
我怎样才能以相当简单的方式更新它(即,不是在 Swift 中重写,而不是用故事板重构应用程序——Xcode 似乎不能通过复制/粘贴来促进)?而且,为了其他可能会遇到这个问题的人的利益,如果我从头开始写这个,那么实现这个结果的更正确的方法是什么(关于方向改变的新 VC)?
谢谢。
【问题讨论】:
标签: ios objective-c iphone uiviewcontroller uiinterfaceorientation