15

tôi trình bày một bộ điều khiển xem với nhau:"viewWillTransitionToSize:" không được gọi trong iOS 9 khi bộ điều khiển xem được trình bày modally

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

Sau đó, trong phần giới UIViewController, phương pháp viewWillTransitionToSize:withTransitionCoordinator: được gọi trong iOS 8 nhưng không trong iOS 9 ...

Cảm ơn

+0

Tôi cũng đang gặp phải sự cố tương tự. – iChirag

Trả lời

20

trong điều khiển xem hiện tại của bạn, nếu bạn ghi đè viewWillTransitionToSize:withTransitionCoordinator:, hãy chắc chắn bạn gọi super. Nếu không, thông báo này sẽ không được truyền cho trẻ em xem bộ điều khiển.

Đối 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 ... 
} 
2

Có vẻ một trường hợp tầm thường, nhưng khi sử dụng séc iPad mà người dùng đã không được kích hoạt khóa xoay trong bảng điều khiển hoặc cài đặt hoặc nút bên cạnh

Các vấn đề liên quan