Вопрос

I have a signature screen in my application that is suppose to show in Landscape, but the iPhone status bar displays in Portrait mode. How to get the Status bar to show in Landscape mode instead of portrait mode? I tried setting the Landscape orientation to status bar in ViewDidLoad, but no luck..

I use presentViewController to push screen,

enter image description here

Please find the below snippet of code to push the screen to Landscape mode.

// Override to allow orientations other than the default Landscape orientation.
- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}


- (BOOL) shouldAutorotate {
    return YES;
}


- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeRight;
}

Any help is greatly appreciated!

Thanks, Ramesh

Это было полезно?

Решение 2

Resolved by adding the following methods,

- (void)viewWillAppear:(BOOL)animated {
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
}

- (void)viewWillDisappear:(BOOL)animated {
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];

}

Другие советы

change this method

- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeRight;

}

and also this properties: In your project -> General -> Device Orientation, check Portrait and Landscape Right.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top