【发布时间】:2011-07-05 17:18:23
【问题描述】:
视图控制器 A 以水平方向显示视图控制器 B
#pragma mark Rotation Delegate Methods
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return YES;
}
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
[landscapeChartViewController.chartImageView reloadWithUrl:
[NSString stringWithFormat:@"someurl",[symbol uppercaseString]]];
NSLog(@"showing chart");
[self presentModalViewController:landscapeChartViewController animated:NO];
}
}
这很好用。视图控制器 B 以横向显示。这是 View Controller B 的实现:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
NSLog(@"dismissing chart");
[self.parentViewController dismissModalViewControllerAnimated:NO];
}
}
问题是,当我返回纵向显示视图控制器 A 时,视图控制器 A 卡在横向。我该如何解决这个问题?
【问题讨论】:
标签: iphone objective-c cocoa-touch uiview uiviewcontroller