Leo*_*eon 5 rotation uisplitviewcontroller screen-rotation ios objective-c-category
我有一个标签式应用程序,其中一个选项卡中有一个UISplitView.
我正在使用UITabBarController + iAds,并且有一个开发人员到目前为止无法解决的问题.
不幸的是,这就是我的UI在旋转iPad时的样子:

从AppDelegate中调用该类别,以下代码用于在旋转设备时刷新广告:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
NSLog(@"Did rotate");
[self layoutBanner];
}
Run Code Online (Sandbox Code Playgroud)
据我了解,这是阻止MasterViewController正常工作但我不完全理解方法调用级联背后的原理,以了解如何解决此问题.
以下是Apple开发人员指南对didRotateFromInterfaceOrientation方法的说明:
子类可以覆盖此方法以在旋转后立即执行其他操作.
...
您执行此方法必须在执行期间的某个时刻调用super.
我最好的猜测是,视图控制器中的某些绘制操作不会发生,因为您没有从实现中调用超类方法.尝试解决这个问题:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
NSLog(@"Did rotate");
[self layoutBanner];
}
Run Code Online (Sandbox Code Playgroud)
更新: 在iOS 8上,不推荐使用此方法,并且在旋转设备时不再调用此方法.相反,您需要使用新方法:
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
NSLog(@"Szie changed");
[self layoutBanner];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2287 次 |
| 最近记录: |