不推荐使用 didRotateFromInterfaceOrientation 吗?

M S*_*nil 1 deprecated screen-orientation ios xcode8.1

我正在尝试实现 didRotateFromInterfaceOrientation 方法来通知方向更改,但在 iOS 10 和 Xcode 8.1 中它显示为 deprecate 方法。

在此处输入图片说明

它被弃用了吗?如果是,那么替代品是什么?

Nar*_*dey 5

我认为它已被弃用,取而代之的是这种方法。

- (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];
}
Run Code Online (Sandbox Code Playgroud)