Ald*_* Co 8 iphone objective-c uideviceorientation
当屏幕方向从横向更改为纵向时,如何更改或禁用旋转动画,反之亦然?
Nil*_*nch 16
是的,可以禁用动画,而不会破坏一切.
以下代码将禁用"黑匣子"旋转动画,而不会弄乱其他动画或方向代码:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[UIView setAnimationsEnabled:YES];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
[UIView setAnimationsEnabled:NO];
/* Your original orientation booleans*/
}
Run Code Online (Sandbox Code Playgroud)
把它放在你的UIViewController中,一切都很好.相同的方法可以应用于iOS中的任何不需要的动画.
祝你的项目好运.
如果您不希望视图控制器旋转,只需覆盖shouldAutoRotateToInterface视图控制器方法,以便为您不想支持的任何方向返回false ... 这是一个参考.
在你只是想以其他方式处理旋转的情况下,你可以在上面的方法中返回false并注册UIDeviceOrientationDidChangeNotification,就像这样
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self
selector:@selector(handleOrientationDidChange:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
Run Code Online (Sandbox Code Playgroud)
现在,当你收到通知时,你可以随心所欲地做任何事......
| 归档时间: |
|
| 查看次数: |
9352 次 |
| 最近记录: |