旋转肖像景观2XIB
-
21-09-2019 - |
题
我有2的图形用户界面和2个控制器 1被称为landscapeguicontroller和第二被称为highguicontroller.
现在一般我叫highguicontroller,当我转动我的iphone它检测,然后它显示了landscapeguicontroller:代码:
landscapeguicontroller *neu =[[landscapeguicontroller alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:neu animated:YES];
[self dismissModalViewControllerAnimated:YES];
问题是,然后该动画推动新的窗口中,从超越边的iphone成的窗口。
在Landscapeguicontroller,我已经增加到如下:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
当我想回到highguicontroller我呼吁:
[self dismissModalViewControllerAnimated:YES];
所有工作,但只是在第二个动画我看到的是正确的"旋转动画"。你有什么建议吗?
所以一个简短的问题说明:1.动画从高到景观的景观被推入窗口 但在2.动画从横向高,转动看起来像一个真正的转...
我想1中。动画看起来像2.动画
最好的问候 Ploetzeneder
解决方案
为了避免"问题,然后将该动画推动新的窗口中,从超越边的iphone成的窗口。", 试图设置的图控制器的modalTransitionStyle酒店之一以下,无论你喜欢:typedef enum{ UIModalTransitionStyleCoverVertical=0, UIModalTransitionStyleFlipHorizontal, UIModalTransitionStyleCrossDissolve, }UIModalTransitionStyle;
此外,如果你想要避免的动画旋转,可以设置你的shouldRotate...方法不允许其它的方位,但随后设立了接收通知的当设备的物理改变方向,并提出你的模式viewcontroller当在适当的方向。看苹果的"AlternateViews"样品代码为这样的一个例子。
通知中反映的物理方向的装置,以及可以接收他们的接口是否允许更改或没有。(你可以看看UIApplications的statusBarOrientation酒店看到的是什么方向的)。
其他提示
它听起来像是你想要的顺序,是这样的:
- 物理上旋转设备,从纵向横向
- 动画的肖像图(
highguicontroller
)到风景 - 推景(
landscapeguicontroller
)从新的"自下而上"的屏幕
如果这是正确的,则需要有类似于以下你的 highguicontroller
执行:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
}
这将需要护理的步骤2(它将旋转的肖像看到的景观在任何一方向)。
然后你会想要的东西,像这样:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if(fromInterfaceOrientation == UIInterfaceOrientationPortrait) {
[self presentModalViewController:landscapeguicontroller animated:YES];
}
else {
[self dismissModalViewControllerAnimated:YES];
}
}
这应该本的风景之后的旋转画完成,然后驳回之后,设备被转回到肖像。
希望这可以帮助!