11

我有一个 iPhone 应用程序,我目前正在将其转换为通用二进制文件以与 iPad 一起使用。我已经成功地实现了我在布局方面所需的一切,因此我的应用程序现在支持完整的横向功能(以前我主要使用纵向模式来显示内容)。

但是,我有一个奇怪的问题,它只发生在横向模式下:当我将视图控制器推入堆栈时,需要在后退按钮上点击两次才能返回到前一个视图控制器!第一次点击显示一个空白视图,但在左侧后退导航按钮上具有相同的名称,第二次点击将控制器返回到以前的视图,就像它应该的那样。

我没有要测试的 iPad,所以我依靠模拟器。如果您旋转回纵向模式,该问题不会出现在 iPhone 上并且不会出现。

我的应用程序由一个 tabbarcontroller 和为其 vc 加载的导航控制器组成:

//application delegate
- (void)applicationDidFinishLaunching:(UIApplication *)application
//....
WebHelpViewController *vc8 = [[WebHelpViewController alloc] init];
UINavigationController *nv8 = [[UINavigationController alloc] initWithRootViewController:vc8];

[self.tabBarController setViewControllers:[NSArray arrayWithObjects:nv1,nv2,nv3,nv4,nv5,nv6,nv7,nv8,nil]];

为了实现横向功能,UITabBarController 被覆盖以在需要时自动旋转:

//CustomTabBarController.m
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return [[(UINavigationController *)self.selectedViewController topViewController] shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

... 工作正常。我使用这种方法导航到新视图

SomeViewController *vc = [[SomeViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
[vc release];

这只是一个模拟错误吗?我该如何解决这个问题?

4

1 回答 1

10

听起来另一个ViewController人正在回应:

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

首先检查这个。

于 2010-04-22T21:31:13.250 回答