2
横を回転させるとモーダルビューコントローラが表示されます。ポートレートにいるときにモーダルビューコントローラを削除したいです。何らかの理由で、私がポートレートモードに入ったときに私のログステートメントが表示されません。iPhoneで縦向きを検出できません
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
NSLog(@"showing chart");
[self presentModalViewController:landscapeChartViewController animated:NO];
}
if (toInterfaceOrientation == UIInterfaceOrientationPortrait ||
toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
NSLog(@"dismissing chart");
[self.parentViewController dismissModalViewControllerAnimated:NO];
}
}
あなたのコードははるかにクリーンであり、ロジックは正しいです。本当にありがとう。 –