我有一个包含 uitableview 的主视图,当用户点击一行时,我正在推送另一个视图。我只希望子视图旋转并为此编写代码。但问题是,一旦我推送视图,它也会启用主视图上的方向。
当我向左旋转主视图时,状态栏也会向左移动。我没有在主视图上应用任何方向。我在 MainView 上完成了以下操作,但代码仍然状态栏没有改变。
-(void) viewDidLoad
{
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(receivedRotate:) name: UIDeviceOrientationDidChangeNotification object: nil];
}
-(void) receivedRotate: (NSNotification*) notification
{
UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];
if(interfaceOrientation != UIDeviceOrientationUnknown)
{
if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft)
{
[self shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
}
}
如何在主视图中禁用 interfaceOrientation?