2

我有一个像这样调用的全屏 modalView:

PreferencesController *nextWindow = [[[PreferencesController alloc] initWithNibName:@"Preferences" bundle:nil] autorelease];
UINavigationController* navController = [[[UINavigationController alloc] initWithRootViewController:nextWindow] autorelease];
[self presentModalViewController:navController animated:YES];

然后从这个 modalView 我推另一个视图:

    MyController *nextWindow = [[[MyController alloc] initWithNibName:@"tmp" bundle:nil] autorelease];
    [self.navigationController pushViewController:nextWindow animated:YES];

在这个新控制器中,我有这个 viewDidLoad :

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"Borders";
    self.navigationController.navigationBarHidden = NO;
}

leftBarButtonItem 未激活,我的意思是触摸它不会突出显示它,也不会返回上一个视图。

我的视图全屏显示,并[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];在应用程序初始化时调用。

导航栏框架为 0,0,320,44。
navigationBar 超视图框架为 0,0,320,480。
viewController 视图框架为 0,0,320,436。

我试图调用 viewDidLoadself.navigationController.navigationBar.userInteractionEnabled = YES;并且self.navigationItem.leftBarButtonItem.enabled = YES;没有效果。

怎么了?

编辑:
我的 self.navigationController.navigationItem.backBarButtonItem 为零。self.navigationController.navigationItem 不是 NIL

4

3 回答 3

1

每当这种反应迟钝发生在我身上时,总是因为框架问题。即 NavigationController 的父视图小于 NavigationController 的视图。我知道您说所有内容都设置为全屏,但我会通过为层次结构中的每个视图打开“clipsSubviews”来验证所有内容实际上都是全屏的。

于 2011-03-19T16:31:45.947 回答
0

我刚遇到这个问题,我不确定为什么会这样,但不是这样做:

UIBarButtonItem *backButton =
[[[UIBarButtonItem alloc] initWithTitle:@"Back"
                                  style: UIBarButtonItemStyleBordered
                                 target:nil
                                 action:nil] autorelease];

self.navigationItem.leftBarButtonItem = backButton;

我将第二行替换为

 self.navigationController.navigationItem.leftBarButtonItem = backButton;

这对我行得通。

于 2011-03-20T00:37:26.390 回答
0

我找到了解决方案。问题是第一个视图是从叠加层调用的,而不是从选择器调用的。将 Picker 的引用保存到覆盖层中,并从中调用视图可以解决问题:

从覆盖:

[self.picker presentModalViewController:navController animated:YES];

作品

代替:

[self presentModalViewController:navController animated:YES];
于 2011-03-21T23:25:38.470 回答