iPad&x27;旋转modalView时,s UISPlitView控制器旋转不好

iPad&x27;旋转modalView时,s UISPlitView控制器旋转不好,ipad,rotation,uisplitviewcontroller,Ipad,Rotation,Uisplitviewcontroller,我在UISplitViewController上有旋转问题。在我的例子中,在调用splitViewController(此splitViewController是窗口的根视图)上的present model以显示另一个视图之后。旋转该modalView时,splitView旋转不正确 splitView看起来像是旋转的,但是DetailViewController保持它在纵向上的显示,而RootViewController根本没有显示。它的行为仍类似于“纵向”模式。splitView似乎是旋转的

我在
UISplitViewController
上有旋转问题。在我的例子中,在调用
splitViewController
(此splitViewController是窗口的根视图)上的present model以显示另一个视图之后。旋转该modalView时,splitView旋转不正确

splitView看起来像是旋转的,但是
DetailViewController
保持它在纵向上的显示,而
RootViewController
根本没有显示。它的行为仍类似于“纵向”模式。splitView似乎是旋转的,但底层视图没有旋转(
DetailViewController
RootViewController

我尝试在modalView上实现
willRotateToInterfaceOrientation
,并使用委托调用splitView的
willRotateToInterfaceOrientation
方法

这是我在modalView中实现的:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
    MacProjectAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
    [delegate.splitViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
ModalViewController *modalView = [[ModalViewController alloc] init];
MacProjectAppDelegate *delegate = (MacProjectAppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.splitViewController presentModalViewController:modalView animated:YES];
[modalView release];
结果是,
DetailViewController
行为正确,但与
RootViewController
不一致。它一直隐藏着。在用户手动旋转到纵向并返回到横向后,它将重新出现。但显然,用户不希望这样

这就是我在介绍modalView时所做的:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
    MacProjectAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
    [delegate.splitViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
ModalViewController *modalView = [[ModalViewController alloc] init];
MacProjectAppDelegate *delegate = (MacProjectAppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.splitViewController presentModalViewController:modalView animated:YES];
[modalView release];
在这种情况下,是否有办法显示
RootViewController
?还是我做错了

编辑:
似乎所有视图都没有按照modalView旋转。RootViewController和DetailViewController都没有旋转(两个ViewController上的DidRotateFromoritation根本没有调用)。现在我假设它没有随着设备/modalView旋转。

好的。我的问题已经解决了。 我所做的就是写下对舒拉科夫评论的评论

我获取appDelegate并让splitViewController调用willRotateToInterfaceOrientation

MacProjectAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.splitViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
我做了两次,因为其中只有一个似乎不起作用(我不知道为什么)。一个位于
modalViewController
将旋转接口定向
方法,一个位于
RootViewController的
将出现
方法

要删除
DetailViewController
上的navigator/popover按钮,我只需在
RootViewController
方法中调用
invalidaterootpopooverbuttonItem
即可使该按钮无效。这就是这个特定方法的外观(对于
modalViewController
中的第一个方法,我只需将
willRotateToOrientation
命令传递给
splitViewController
):


希望这能解释我如何克服我的问题,并帮助任何和我有同样问题的人。

好的。我的问题已经解决了。 我所做的就是写下对舒拉科夫评论的评论

我获取appDelegate并让splitViewController调用willRotateToInterfaceOrientation

MacProjectAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.splitViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
我做了两次,因为其中只有一个似乎不起作用(我不知道为什么)。一个位于
modalViewController
将旋转接口定向
方法,一个位于
RootViewController的
将出现
方法

要删除
DetailViewController
上的navigator/popover按钮,我只需在
RootViewController
方法中调用
invalidaterootpopooverbuttonItem
即可使该按钮无效。这就是这个特定方法的外观(对于
modalViewController
中的第一个方法,我只需将
willRotateToOrientation
命令传递给
splitViewController
):


希望这可以解释我如何克服我的问题,并帮助任何与我有相同问题的人。

您是否尝试从
DetailViewController
而不是直接从UISplitView演示您的modalViewController?我尝试过,但它不起作用。到目前为止,我训练的解决方案是获取
appDelegate
,并让
splitViewController
调用
willrotatetointerfaceooritation
两次。一个位于
modalView
将旋转到接口定向
方法,一个位于
RootViewController的
将出现
方法。但这种方法仍然存在问题
DetailViewController
仍会像在纵向模式下一样显示navigator按钮。我还在做这个,我也有同样的问题。看看我的解决方案,您是否尝试过从
DetailViewController
而不是直接从UISplitView演示您的modalViewController?我已经尝试过了,但它不起作用。到目前为止,我训练的解决方案是获取
appDelegate
,并让
splitViewController
调用
willrotatetointerfaceooritation
两次。一个位于
modalView
将旋转到接口定向
方法,一个位于
RootViewController的
将出现
方法。但这种方法仍然存在问题
DetailViewController
仍会像在纵向模式下一样显示navigator按钮。我还在做这个,我也有同样的问题。看看我的解决方案