任何人都可以提供帮助,下面的代码在应用程序启动时从纵向视图开始工作,如果我旋转到横向如果效果很好并显示新视图,但是当旋转回到肖像时,而不是获取原始视图,我只是得到一次崩溃,非常感谢
`
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self enableRotation];
}
- (void)didRotate
{
[self setNeedsStatusBarAppearanceUpdate];
if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft ||
[UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight) {
[self performSegueWithIdentifier: @"segueToNumbers"sender: self];
}
else if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait ||
[UIDevice currentDevice].orientation == UIDeviceOrientationPortraitUpsideDown){
[self performSegueWithIdentifier: @"segueToChoose"sender: self];
}
}
- (void)enableRotation
{
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate)
name:UIDeviceOrientationDidChangeNotification
object:nil];
}
`
答案 0 :(得分:0)
不要回应旋转事件。您需要使用AutoLayout设计UI以适应不同的屏幕大小。在iOS 8中,方向是无关紧要的,您的代码应该考虑大小类