2014-10-01 18 views
6

Xin chào Tôi có vấn đề với việc xoay vòng một Chế độ xem được hiển thị theo kiểu Modal trong iOS8. Tất cả điều này hoạt động tốt trên iOS7 và thấp hơn.iOS8 Modal ViewController Rotation issue

App Struct:

  • RootController (hỗ trợ Định hướng: Portrait)
  • phương thức trình bày ViewController (hỗ trợ Định hướng: Tất cả)

Vấn đề của tôi là khi tôi Xoay thiết bị khi điều khiển phương thức được trình bày khung nhìn của Modal Controller đã không thay đổi kích thước cho khung lanscape.

Hình như vậy:

enter image description here Các phương pháp xoay được gọi và khi tôi đặt khung của chế độ xem để cảnh quan tự các tương tác người dùng của phía bên phải (màn hình bên màu xám) đã không làm việc.

đang RootController:

đang
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return UIInterfaceOrientationPortrait; 
} 

- (NSUInteger) supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskPortrait; 
} 

phương thức điều khiển:

- (NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskAll; 
} 


- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
             duration:(NSTimeInterval)duration 
{ 
    if (self.presentingViewController != nil) { 
     [self.presentingViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation 
                     duration:duration]; 
    } 
} 

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
           duration:(NSTimeInterval)duration 
{ 
    if (self.presentingViewController != nil) { 
     [self.presentingViewController willRotateToInterfaceOrientation:toInterfaceOrientation 
                   duration:duration]; 
    } 
} 

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{ 
    if (self.presentingViewController != nil) { 
     [self.presentingViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation]; 
    } 
} 

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

    [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) { 

    } completion:^(id<UIViewControllerTransitionCoordinatorContext> context) { 

    }]; 
} 

Bất kỳ một thể giúp tôi để khắc phục vấn đề này cho iOS8.

+1

Bạn đã đặt autoresizingMask's trên các phần tử giao diện người dùng của mình chưa? – Jasper

Trả lời

1

Bạn trình bày bộ điều khiển chế độ xem phương thức như thế nào? Tại sao bạn tự chuyển tiếp các phương thức xoay? Khi được thực hiện đúng cách, điều này sẽ được xử lý tự động và tất cả những gì bạn cần là các phương thức -supportedInterfaceOrientations (và như ghi chú Jasper, các ràng buộc tự động hóa, hoặc bố cục tự động, cần phải chính xác).