objective-c – didRotateFromInterfaceOrientation:没有为在iO
发布时间:2020-12-16 06:58:31 所属栏目:百科 来源:网络整理
导读:有一个视图控制器(让我们将其命名为parent),它使用presentModalViewController:animated:来呈现其他视图控制器(让我们将其命名为模态),然后旋转设备.两个控制器都支持所有方向.这里发生了什么: 旋转后,模态控制器接收didRotateFromInterfaceOrientation:
有一个视图控制器(让我们将其命名为parent),它使用presentModalViewController:animated:来呈现其他视图控制器(让我们将其命名为模态),然后旋转设备.两个控制器都支持所有方向.这里发生了什么:
>旋转后,模态控制器接收didRotateFromInterfaceOrientation: 那么,如果在模态控制器可见时旋转设备,我该怎么做才能正确地将父控制器的界面更新为新的方向? 解决方法
我遇到过类似的问题.我的解决方案是将我的方向处理代码移动到一个单独的方法中,并从旋转方法和viewWillAppear调用:
//.h @interface SomeViewController - (void)layoutForInterfaceOrientation:(UIInterfaceOrientation)orientation; @end //.m @implementation SomeViewController - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; UIInterfaceOrientation currentOrientation = [[UIApplication sharedApplication] statusBarOrientation]; [self layoutForInterfaceOrientation:currentOrientation]; } - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toOrientation duration:(NSTimeInterval)duration { [self layoutForInterfaceOrientation:toOrientation]; } - (void)layoutForInterfaceOrientation:(UIInterfaceOrientation)orientation { // layout views } @end (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |