Iphone 在iOS中关闭默认旋转动画
当我将iDevice窗体的纵向旋转到横向时,屏幕旋转得很好,但我看到黑色边框也随之移动,所以看起来更“真实”。我觉得在iOS 7中看到这种行为很尴尬,很多应用程序都对这种行为进行了抨击(比如Instagram)Iphone 在iOS中关闭默认旋转动画,iphone,ios,cocoa-touch,animation,uikit,Iphone,Ios,Cocoa Touch,Animation,Uikit,当我将iDevice窗体的纵向旋转到横向时,屏幕旋转得很好,但我看到黑色边框也随之移动,所以看起来更“真实”。我觉得在iOS 7中看到这种行为很尴尬,很多应用程序都对这种行为进行了抨击(比如Instagram) 我想做的是隐藏那些在旋转设备时看起来完全不必要的黑色边框。如何禁用此标准动画?在父视图控制器viewdidload方法中添加以下内容: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(di
我想做的是隐藏那些在旋转设备时看起来完全不必要的黑色边框。如何禁用此标准动画?在父视图控制器viewdidload方法中添加以下内容:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
然后添加此方法
- (void) didRotate:(NSNotification *)notification {
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (UIInterfaceOrientationIsLandscape(orientation) && !self.modalViewController) {
[self presentModalViewController:carouselView animated:YES];
[Globals sharedGlobals].startedAtLandscape = YES;
}
if (UIInterfaceOrientationIsPortrait(orientation) && self.modalViewController) {
[self dismissModalViewControllerAnimated:YES];
[Globals sharedGlobals].startedAtLandscape = NO;
}
}
然后,要防止动画,请执行以下操作:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
return NO;
}
return YES;
}
我发现最好的解决方案是在旋转前关闭动画,然后在旋转后将其返回
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
{
...
[UIView setAnimationsEnabled:NO];
}
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
...
[UIView setAnimationsEnabled:YES];
}
在正常状态下工作正常吗?@GANAPATH我描述的是正常状态:)是否可以共享您的屏幕(隐藏官方内容)@GANAPATH不必麻烦,问题已经解决)虽然您的代码示例非常主观,但我已经设法做到了这一点,首先提交动画,然后使用
[UIView SetAnimationEnabled:NO];
然后在持续时间后将其设置为是
。效果很好。