我已经使用iOS 5 SDK创建了一个主细节应用程序,打算在设备是纵向时以模态方式显示UIViewController,在设备是横向时使用UISplitViewController .
使用以下方法旋转到横向时,模态VC将被解除:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
if(UIInterfaceOrientationIsLandscape(toInterfaceOrientation)){
[self dismissModalViewControllerAnimated:YES];
}
}
但是UISplitViewController永远不会获得旋转事件,因此最终会在横向窗口中以纵向“模式”结束 .
我试过在DetailViewController中的viewWillAppear中触发一个旋转,如下所示:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
}
}
,尝试调用SplitViewController的 willRotateToInterfaceOrientation
,并尝试从我的模态调用SplitViewController上的 didRotateFromInterfaceOrientation
但没有任何效果 .
有任何想法吗?