我正在解决这个问题:/我已经尝试过其他SO主题的解决方案,但是到目前为止还没有运气。
这是错的: 我有一个UINavigationController推动View A,从View A我可以按一个按钮来推动View B - 工作正常。但是当我按下View B,然后将屏幕旋转到横向模式,然后单击后退按钮,我在控制台中得到以下输出,并且视图切换没有动画,只是从B切换回A:
2012-01-02 20:50:42.866 [13345:f803] Unbalanced calls to begin/end appearance transitions for <DimensionConversionViewController: 0x68831f0>.
2012-01-02 20:50:42.868 [13345:f803] attempt to dismiss modal view controller whose view does not currently appear. self = <UINavigationController: 0x6b541a0> modalViewController = <UISnapshotModalViewController: 0x6da5190>
这就是我将View B推入堆栈的方式:
- (void) showConverter:(id)sender {
[self.navigationController pushViewController:converter animated:YES];
}
- 查看B的-viewDidLoad:
- (void) viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateInterface) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
// ... Update text fields ...
[self updateInterface];
}
-viewDidUnload of View B:
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"UIDeviceOrientationDidChangeNotification" object:nil];
}
如果您有任何问题或需要更多代码示例,请告知我们。
提前感谢您的帮助: - )
答案 0 :(得分:11)
事实证明,在我的情况下,问题的根本原因是,我忘了更新不同视图控制器中的所有shouldAutorotateToInterfaceOrientation:
方法,以便为所有UIInterfaceOrientations
返回YES(或者让我们说它们应该都回归山姆)。这样做解决了这个问题。