简体   繁体   中英

how to rotate to current of Orientation?

according to my code when my device are use in Landscape

when i pushViewController it will

automatic show in UIDeviceOrientationPortrait.

i need to rotate my device to Portrait and then rotate to Landscape,

then it will present in Landscape mode.

how can i rotate to current of Orientation with out use of private API(setOrientation)?

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIDeviceOrientationPortrait) ||
            (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}

Try setting the status bar orientation:

UIApplication *app = [UIApplication sharedApplication];
[app setStatusBarOrientation: UIInterfaceOrientationLandscape];
[app setStatusBarHidden: NO animated: YES];

You can get the current device orientation like this:

[UIDevice currentDevice].orientation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM