15

stelle ich einen View-Controller von einem anderen ein:"viewWillTransitionToSize:" nicht in IOS 9 aufgerufen, wenn die View-Controller-modal präsentiert wird

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

dann in der dargestellten UIViewController, wobei das Verfahren viewWillTransitionToSize:withTransitionCoordinator: wird in iOS 8 genannt, aber nicht in iOS 9 ...

Dank

+0

Ich bin auch vor demselben Problem. – iChirag

Antwort

20

in Ihrem aktuellen view-Controller, wenn Sie viewWillTransitionToSize:withTransitionCoordinator: außer Kraft setzen, stellen Sie sicher, dass Sie rufen super. Andernfalls wird diese Nachricht nicht an untergeordnete View-Controller weitergegeben.

Für Objective-C:

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

    // Your other code ... 

Und Swift:

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

    // Your other code ... 
} 
2

Mai trivialer Fall erscheinen, aber wenn eine iPad Prüfung mit, dass der Benutzer nicht Rotationssperre aktiviert in den Einstellungen oder Bedienfeld oder Seitentaste