我使用iOS5和故事板,我创建了两个ViewController,一个用于纵向方向,一个用于横向。 我用两个“模态segue”连接了两个视图,这是我使用的代码:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
if (UIDeviceOrientationIsLandscape(deviceOrientation))
{
[self performSegueWithIdentifier: @"aaaa" sender: self];
}
else if (deviceOrientation == UIDeviceOrientationPortrait)
{
[self performSegueWithIdentifier: @"ddd" sender: self];
}
return true;
}
如果我从纵向更改为横向,则可以正常工作,但是当我返回纵向视图时,它会因“没有带标识符'ddd'的segue”而崩溃,但它存在。
感谢。
答案 0 :(得分:0)
我解决了在视图之间设置模式选择的问题,然后使用以下代码将其设置到实现文件中:
- (void)willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
if(self.interfaceOrientation == UIDeviceOrientationPortrait || self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown){
[self performSegueWithIdentifier: @"aaaa" sender: self];
} else if(self.interfaceOrientation == UIDeviceOrientationLandscapeLeft || self.interfaceOrientation == UIDeviceOrientationLandscapeRight)
{
[self performSegueWithIdentifier: @"ddd" sender: self];
}
}
同时使用ViewController(纵向和横向)课程。