iOS 13 如果应用程序以 iPhone 横向启动,则应用程序 window 在 iPhone 上错误旋转
iOS 13 Application window is wrongly rotated on iPhone if app is started with iPhone in landscape orientation
我正在为 iOS 13 (Xcode 11.4) 升级 10 年前的 iOS 应用程序 (Objective-C) 并注意到以下奇怪的问题问题:当 iPhone(模拟器,13.4)处于横向时启动应用程序时,应用程序的 window 具有正确的尺寸,但奇怪地向右旋转了 90 度。这不会发生在应用程序正确启动的 iPad(模拟器,13.4)或 iPhone 模拟器 12.x 上。
附上截图以更好地说明问题。
该应用程序使用 XIB 和以编程方式创建的视图,没有故事板。
初始视图是在 application didFinishLaunchingWithOptions
中以通常的方式创建的:
[self.window addSubview:tabBarController.view];
self.window.rootViewController = tabBarController;
[self.window makeKeyAndVisible];
tabBarController
从 XIB 加载。
启动屏幕(应用程序中唯一的故事板)显示正确。
有什么想法吗?
结果是删除行
[self.window addSubview:tabBarController.view];
在 application didFinishLaunchingWithOptions
中成功了。显然这条线曾经需要,但现在造成了严重破坏。
删除该行还修复了我在日志输出中看到的 Unbalanced calls to begin/end appearance transitions for <UITabBarController: ...>
消息。
另请参阅 Apple 开发者论坛中的 this answer,这让我走上了正确的轨道。
我正在为 iOS 13 (Xcode 11.4) 升级 10 年前的 iOS 应用程序 (Objective-C) 并注意到以下奇怪的问题问题:当 iPhone(模拟器,13.4)处于横向时启动应用程序时,应用程序的 window 具有正确的尺寸,但奇怪地向右旋转了 90 度。这不会发生在应用程序正确启动的 iPad(模拟器,13.4)或 iPhone 模拟器 12.x 上。
附上截图以更好地说明问题。
该应用程序使用 XIB 和以编程方式创建的视图,没有故事板。
初始视图是在 application didFinishLaunchingWithOptions
中以通常的方式创建的:
[self.window addSubview:tabBarController.view];
self.window.rootViewController = tabBarController;
[self.window makeKeyAndVisible];
tabBarController
从 XIB 加载。
启动屏幕(应用程序中唯一的故事板)显示正确。
有什么想法吗?
结果是删除行
[self.window addSubview:tabBarController.view];
在 application didFinishLaunchingWithOptions
中成功了。显然这条线曾经需要,但现在造成了严重破坏。
删除该行还修复了我在日志输出中看到的 Unbalanced calls to begin/end appearance transitions for <UITabBarController: ...>
消息。
另请参阅 Apple 开发者论坛中的 this answer,这让我走上了正确的轨道。