在我的一个仅支持纵向方向的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;
}
答案 0 :(得分:0)
使用此方法将其保留在纵向视图中:
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationPortrait;