fab*_*abb 52 rotation ios ios8
在iOS 8中,不推荐使用接口轮换方法.这包括:
willRotateToInterfaceOrientation:duration:didRotateFromInterfaceOrientation:willAnimateRotationToInterfaceOrientation:duration:替代方法包括:
willTransitionToTraitCollection:withTransitionCoordinator:viewWillTransitionToSize:withTransitionCoordinator:如果未实现新的旋转方法,并且使用iOS 8 SDK编译项目,则视图控制器将不会接收调用 - 不推荐的旋转方法.
我担心的是:使用iOS 7 SDK构建的AppStore中的应用程序会发生什么变化?是否仍会在iOS 8设备上调用已弃用的旋转方法?
编辑:
仍然会调用旋转方法,但iOS 8中存在一些更改/问题/错误.
Cam*_*amo 36
我只是有这个问题,我想用我用之前(至少目前如此)同样的方法,所以这是我做的.
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
//The device has already rotated, that's why this method is being called.
UIInterfaceOrientation toOrientation = [[UIDevice currentDevice] orientation];
//fixes orientation mismatch (between UIDeviceOrientation and UIInterfaceOrientation)
if (toOrientation == UIInterfaceOrientationLandscapeRight) toOrientation = UIInterfaceOrientationLandscapeLeft;
else if (toOrientation == UIInterfaceOrientationLandscapeLeft) toOrientation = UIInterfaceOrientationLandscapeRight;
UIInterfaceOrientation fromOrientation = [[UIApplication sharedApplication] statusBarOrientation];
[self willRotateToInterfaceOrientation:toOrientation duration:0.0];
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[self willAnimateRotationToInterfaceOrientation:toOrientation duration:[context transitionDuration]];
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[self didRotateFromInterfaceOrientation:fromOrientation];
}];
}
Run Code Online (Sandbox Code Playgroud)
我仍然不知道我是否应该使用这种动画块外,因为我没有时间.
[self willRotateToInterfaceOrientation:toOrientation duration:0.0];
Run Code Online (Sandbox Code Playgroud)
mlu*_*own 19
iOS 8 SDK中不推荐使用旋转方法.这对使用iOS 7 SDK构建的应用程序完全没有影响,甚至可以在iOS 8和iOS的未来版本中运行.
例如,自iOS 3.0以来,该font属性UIButton已被弃用,并且仍可在iOS 7.0中使用.
当应用程序在iOS 8+设备上运行时,仍会调用您已列出的已弃用的轮播方法.如果您支持iOS 7,则可以继续使用它们而不会出现问题.如果您只支持iOS 8+,那么使用非弃用方法将是明智之举.
但是,请注意,如果在同一视图控制器中实现新的旋转方法和不推荐的旋转方法,则在iOS 7上运行时,将调用已弃用的方法,而在iOS 8+上,它将仅调用已替换这些方法的新方法已弃用.
例如,如果您只实现willRotateToInterfaceOrientation,则在iOS 7和8上运行时将调用此方法.如果您再添加viewWillTransitionToSize,iOS 7仍将调用willRotateToInterfaceOrientation但iOS 8不会调用,而只会调用viewWillTransitionToSize.
| 归档时间: |
|
| 查看次数: |
48760 次 |
| 最近记录: |