7

在我的一个仅支持纵向方向的 Viewcontroller 中。在我的设备上,当旋转状态栏旋转到横向。视图的其余部分保持纵向模式。我想防止状态栏的旋转。这个问题只发生在IOS7

// Overridden function to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        // iPhone: support only upright portrait
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    else 
    {
           // iPad: any orientation is OK
            return YES;
     }
}

// For iOS6.0 Rotate
- (BOOL)shouldAutorotate
{
    return NO;
}
4

1 回答 1

0

使用此方法将其保持在纵向视图中:

[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationPortrait;
于 2015-04-08T07:22:12.597 回答