デバイスの向きを確認し、メソッドを呼び出して向き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
何が問題なのでしょう?
助けてください!