UITabBarController 内的 UINavigationController,导航控制器中有多个视图

发布于 2024-09-13 00:40:35 字数 850 浏览 7 评论 0原文

我有一个 UINavigationController ,它有一个 UITableViewController 作为根视图。 UINavigationController 位于 UITabBarController 内。

在 UITableViewController (*viewOne) 中,如果我单击一个单元格,则会运行以下代码

UIViewController *newView = [[UIViewController alloc] initWithNibName:@"newView" bundle:nil];
[self.navigationController pushViewController:newView animated:YES];
[newView release];

然后,newView 内部是:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {

        NSLog(@"%@", self.navigationController);

    }
    return self;
}

日志有:

[8947:207] (null)

如果我尝试将新的视图控制器推送到 navigationController,则什么也不会发生。有什么线索吗?

I've got a UINavigationController that has a UITableViewController as it's root view. The UINavigationController is inside a UITabBarController.

In the UITableViewController (*viewOne), if I click a cell a the following code runs

UIViewController *newView = [[UIViewController alloc] initWithNibName:@"newView" bundle:nil];
[self.navigationController pushViewController:newView animated:YES];
[newView release];

Then, inside of newView is:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {

        NSLog(@"%@", self.navigationController);

    }
    return self;
}

The logs have:

[8947:207] (null)

And if I try to push a new view controller to the navigationController, nothing happens. Any clues?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

辞取 2024-09-20 00:40:35

我已经弄清楚了。

在我的应用程序委托中,我添加了一个新属性:

UINavigationController *profileNavigationController;
@property (nonatomic, retain) IBOutlet UINavigationController *profileNavigationController;

在 IB 中,我已将 profileNavigationController 从应用程序委托连接到导航控制器。

现在,在推动新观点时,我会这样称呼:

StartDateSelectorViewController *startDateSelectorViewController = [[StartDateSelectorViewController alloc] initWithNibName:@"StartDateSelectorView" bundle:nil];

Strength_EngineAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.profileNavigationController pushViewController:startDateSelectorViewController animated:YES ];

I've figured it out.

In my application delegate, I've added a new property:

UINavigationController *profileNavigationController;
@property (nonatomic, retain) IBOutlet UINavigationController *profileNavigationController;

And in IB, I've connected the profileNavigationController from the app delegate to Navigation Controller.

And now, when pushing new views, I call:

StartDateSelectorViewController *startDateSelectorViewController = [[StartDateSelectorViewController alloc] initWithNibName:@"StartDateSelectorView" bundle:nil];

Strength_EngineAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.profileNavigationController pushViewController:startDateSelectorViewController animated:YES ];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文