Вы можете немного упростить этот код, это может помочь сузить его.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return YES; // Return YES is the same as entering all interfaces.
}
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
NSLog(@"showing chart");
[self presentModalViewController:landscapeChartViewController animated:NO];
}
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
NSLog(@"dismissing chart");
[self.parentViewController dismissModalViewControllerAnimated:NO];
// self.parentViewController seems like a call FROM the modalViewController.
// This should be moved to the modalViewControllers implementation
}
}
Просто глядя на это, я думаю, что вам нужно отключить контроллер модального представления внутри модального представления, а не внутри родительского представления. Таким образом, вы должны использовать альбомную версию внутри основного контроллера, а затем добавить «willAnimateRotation ...» к модальному контроллеру для обработки портретного вращения.