对开始/结束外观转换的不平衡调用

Bjö*_*ser 2 objective-c uiview uinavigationcontroller

我正在解决这个问题:/我已经尝试过其他SO线程关于这个主题的解决方案,但到目前为止还没有运气.

这是错的:我有一个推动View A的UINavigationController,从View AI可以按一个按钮来推动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>
Run Code Online (Sandbox Code Playgroud)

这就是我将View B推入堆栈的方式:

- (void) showConverter:(id)sender {
    [self.navigationController pushViewController:converter animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

视图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];
 }
Run Code Online (Sandbox Code Playgroud)

-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];
}
Run Code Online (Sandbox Code Playgroud)

如果您有任何疑问或需要更多代码示例,请告知我们.

在此先感谢任何帮助:-)

Bjö*_*ser 11

事实证明,在我的情况下,问题的根本原因是,我忘了更新shouldAutorotateToInterfaceOrientation:不同视图控制器中的所有方法,以便为所有人返回YES UIInterfaceOrientations(或者假设他们都应该返回sam).这样做解决了这个问题.