我正在尝试将状态栏置于正确的横向状态,同时它始终处于纵向位置。我做错了吗?
或者我可以在特定页面的右侧横向上运行状态栏吗?
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
我尝试过这段代码但是没有用。
.h
UIViewController *currentVC;
.m
- (NSUInteger)supportedInterfaceOrientations
{
NSUInteger orientations = UIInterfaceOrientationMaskLandscapeRight;
if ( vertical )
{
orientations = UIInterfaceOrientationMaskPortrait;
}
if (horizontal)
{
orientations = UIInterfaceOrientationMaskLandscapeRight;
}
return orientations;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (BOOL)shouldAutorotate
{
NSLog(@"shouldAutorotate");
return YES;
}
答案 0 :(得分:0)
您的内容是否包含在UINavigationController
中?如果是,请尝试继承UINavigationController
并覆盖prefersStatusBarHidden
- (BOOL)prefersStatusBarHidden
{
return NO;
}
那可能有用吗?