我检查设备的方向,viewDidAppear
并通过调用方法viewWillAppear
强制方向。willAnimateRotationToInterfaceOrientation
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:YES];
_levelComplete = YES;
[self willAnimateRotationToInterfaceOrientation:[[UIDevice currentDevice] orientation] duration:0.01];
}
- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (toInterfaceOrientation == (UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight) )
{
}
else if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
{
}
}
我面临的问题是,方法和方法toInterfaceOrientation
都保持为 0, 因此程序崩溃。viewDidAppear
viewWillAppear
可能是什么问题?
请帮忙!