viewWillTransitionToSize

viewWillTransitionToSize

我提出了另一个 View Controller :

- (void)showModalView
{
   UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
   MySecViewController *mySecViewController = [storyboard instantiateViewControllerWithIdentifier:@"secController"];
   mySecViewController.delegate = self;
   [self presentViewController:mySecViewController animated:YES completion:nil];
}

然后在给出的UIViewController中,在viewWillTransitionToSize:withTransitionCoordinator:中调用iOS 8方法,但在iOS 9中不调用方法...

谢谢

最佳答案

在当前的 View Controller 中,如果您覆盖viewWillTransitionToSize:withTransitionCoordinator:,请确保调用super。否则,此消息将不会传播到子级 View Controller 。

对于 Objective-C :

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];

    // Your other code ...

还有 Swift :
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransition(to: size, with: coordinator)

    // Your other code ...
}

10-07 19:51