1

我将 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”而崩溃,但它存在。

谢谢。

4

1 回答 1

0

我已经解决了在视图之间设置模式segue,然后使用以下代码进入实现文件:

- (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(纵向和横向)的课程。

于 2018-06-24T17:22:53.057 回答