gpt4 book ai didi

ios - 为什么类别中的 didRotateFromInterfaceOrientation 会导致 UISplitView 出现问题?

转载 作者:可可西里 更新时间:2023-11-01 04:29:28 25 4
gpt4 key购买 nike

我有一个选项卡式应用程序,其中一个选项卡中有一个 UISplitView。

我正在使用 UITabBarController+iAds并且有开发人员迄今为止无法解决的问题。

不幸的是,这就是我的 UI 在 iPad 旋转时的样子:

enter image description here enter image description here

该类别从 AppDelegate 中调用,以下代码用于在设备旋转时刷新广告:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
NSLog(@"Did rotate");
[self layoutBanner];
}

据我了解,这会阻止 MasterViewController 正常工作,但我不完全理解级联方法调用背后的原理以了解如何解决此问题。

最佳答案

以下是 Apple 开发人员指南中关于 didRotateFromInterfaceOrientation 的内容方法:

Subclasses may override this method to perform additional actions immediately after the rotation.

...

Your implementation of this method must call super at some point during its execution.

我最好的猜测是 View Controller 中的某些绘图操作不会发生,因为您没有从实现中调用父类(super class)方法。尝试像这样修复它:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
NSLog(@"Did rotate");
[self layoutBanner];
}

更新:在 iOS 8 上,此方法已弃用,并且在设备旋转时不再调用。相反,您需要使用一种新方法:

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
NSLog(@"Szie changed");
[self layoutBanner];
}

关于ios - 为什么类别中的 didRotateFromInterfaceOrientation 会导致 UISplitView 出现问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26000307/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com