不推荐使用旋转方法,相当于'didRotateFromInterfaceOrientation'? [英] Rotation methods deprecated, equivalent of 'didRotateFromInterfaceOrientation'?
问题描述
我正在尝试实现iOS 8中引入的新 viewWillTransitionToSize
方法(所有其他轮换方法都已弃用)。我想知道现在是什么等于 didRotateFromInterfaceOrientation
,因为我们需要执行许多清理任务,我看不到我们可以阻止的块分配给 UIViewControllerTransitionCoordinator
,以便在转换到新大小时完成调用。谢谢。
I'm trying to implement the new viewWillTransitionToSize
method which has been introduced in iOS 8 (all other rotation methods have been deprecated). I'd like to know what the equivalent of didRotateFromInterfaceOrientation
is now as there are a number of clean up tasks we need to perform and I can't see a block that we can assign to UIViewControllerTransitionCoordinator
in order to be called when 'transition' to a new size finishes. Thanks.
推荐答案
好的发现它,只需要使用 animateAlongsideTransition:完成:$ c传递
UIViewControllerTransitionCoordinator
的$ c>方法。
Okay found it, just have to use the animateAlongsideTransition:completion:
method on the passed UIViewControllerTransitionCoordinator
.
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context)
{
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
// do whatever
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context)
{
}];
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}
这篇关于不推荐使用旋转方法,相当于'didRotateFromInterfaceOrientation'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!