8

Trên iOS 8 Tôi có hành vi lạ về thanh điều hướng và thay đổi hướng.iOS 8: Trình bày bộ điều khiển chế độ xem theo chiều dọc khiến kích thước của thanh điều hướng của bộ điều hướng ngang nằm ngang

Tôi có bộ điều khiển điều hướng báo cáo định hướng giao diện được hỗ trợ UIInterfaceOrientationMaskLandscapeRight. Thanh điều hướng có chiều cao dự kiến ​​cho hướng ngang (thật đáng tiếc là tôi không có quyền đăng ảnh chụp màn hình).

Sau đó, tôi bắt đầu trình bày phương thức của bộ điều khiển chế độ xem chỉ hỗ trợ UIInterfaceOrientationMaskPortrait. Khi hoạt ảnh trình diễn bắt đầu, có vẻ như các số liệu của trình điều khiển điều hướng bên dưới được thay đổi thành bản trình bày dọc, vì chiều cao của thanh điều hướng tăng lên kích thước dọc, như được mô tả ở trên.

iOS 7 không thể hiện hành vi này. Tôi đang thiếu gì? Tôi muốn khôi phục lại hành vi cũ.

Đây là mã đầy đủ các ví dụ đơn giản trên:

@implementation AppDelegate 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 


    DOGButtonViewController *root = [DOGButtonViewController new]; 
    DOGOrientedNavigationController *navi = [[DOGOrientedNavigationController alloc] initWithRootViewController:root]; 
    navi.allowedInterfaceOrientations = UIInterfaceOrientationMaskLandscapeRight; 

    self.window.rootViewController = navi; 

    [self.window makeKeyAndVisible]; 
    return YES; 
} 

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 
{ 
    return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortrait; 
} 

@end 


@implementation DOGOrientedNavigationController 

- (NSUInteger)supportedInterfaceOrientations 
{ 
    return self.allowedInterfaceOrientations; 
} 

@end 

@implementation DOGButtonViewController 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    self.title = @"Button View Controller"; 
} 

- (BOOL)prefersStatusBarHidden 
{ 
    return YES; 
} 

- (IBAction)buttonClicked:(id)sender 
{ 
    DOGPortraitViewController *vc = [DOGPortraitViewController new]; 
    [self presentViewController:vc animated:YES completion:nil]; 
} 

@end 

@implementation DOGPortraitViewController 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    self.title = @"Portrait Title"; 
} 

- (NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskPortrait; 
} 

- (IBAction)buttonClicked:(id)sender 
{ 
    [self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; 
} 

- (BOOL)prefersStatusBarHidden 
{ 
    return YES; 
} 

@end 

Trong một thiết lập phức tạp hơn tôi cũng trải qua các văn bản trong một UIWebView chứa trong điều khiển chuyển hướng được nhân rộng khi trình bày các phương thức chân dung. Khi loại bỏ phương thức, văn bản không được thay đổi kích thước về kích thước ban đầu của nó.

+0

Bạn đã quản lý để tìm một giải pháp cho điều này? Tôi đang trải qua điều tương tự –

+0

Đáng buồn là không, nhưng tôi sẽ xem xét điều này trong những ngày sắp tới. – thewulf

+0

Vấn đề tương tự ở đây. Dường như bộ điều khiển hiển thị cũng quay (mặc dù nó không nên) – Carlos

Trả lời

0

Vì thiếu một lựa chọn tốt hơn, tôi đã thực hiện một chút của một hack cho việc này. Về cơ bản trước khi tôi hiển thị chế độ xem phương thức, tôi chụp ảnh màn hình và đặt nó lên trên trình điều khiển chế độ xem trình bày.

Rõ ràng là tôi phải loại bỏ ảnh chụp màn hình này khi xem lại xuất hiện

func showScreenShot() { 
    let image = screenShot() 
    self.screenShotImageView = UIImageView(image: image) 
    self.view.addSubview(self.screenShotImageView!) 
    } 

func screenShot() -> UIImage { 
    UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, true, UIScreen.mainScreen().scale) 
    self.view.layer.renderInContext(UIGraphicsGetCurrentContext()) 
    let image = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    return image 
} 

func removeScreenShot() { 
    if let screenImageView = self.screenShotImageView { 
    screenImageView.removeFromSuperview() 
    self.screenShotImageView = nil 
    } 
} 
Các vấn đề liên quan