Iphone iOS-方向更改时更改视图
我将iOS5与故事板一起使用,创建了两个ViewController,一个用于纵向,另一个用于横向。。 我用两个模态segue连接了两个视图,这是我使用的代码:Iphone iOS-方向更改时更改视图,iphone,ios,uiinterfaceorientation,uistoryboardsegue,Iphone,Ios,Uiinterfaceorientation,Uistoryboardsegue,我将iOS5与故事板一起使用,创建了两个ViewController,一个用于纵向,另一个用于横向。。 我用两个模态segue连接了两个视图,这是我使用的代码: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientatio
- (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”的序列,但它存在
谢谢。我已决定在视图之间设置一个模式段,然后使用以下代码进入实现文件:
- (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纵向和横向的课程。您确定在界面生成器中将segue的标识符设置为ddd吗?