设备旋转时的新视图

时间:2010-04-02 19:21:56

标签: iphone rotation

当iPhone / iPod Touch通过翻转动画旋转到横向模式时,我想调用“presentmodalviewcontroller”。当它旋转回肖像时,我想再次使用翻转动画呈现第一个视图。

无法找到在网络上发挥作用的内容:(

我相信你可以帮助我:) 非常感谢 ! 塞巴斯蒂安

2 个答案:

答案 0 :(得分:1)

尝试侦听UIDeviceOrientationDidChangeNotification通知:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange :) name:UIDeviceOrientationDidChangeNotification object:nil];

当你上手时,出示你的控制器。

答案 1 :(得分:0)

在你的UIViewController中,接受所有接口方向:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}

您的控制器将开始接收轮换消息,例如:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

您可以对旋转做出反应,并执行提示/解除模态视图控件等操作。

相关问题