如何从不同的 TabBar 项目调用相同的 ViewController?

发布于 2024-09-25 16:44:43 字数 187 浏览 0 评论 0原文

我开发了一个ViewController,它根据输入参数显示不同的数据。我想使用 tabBar 界面,并通过将不同选项卡传递给不同参数来调用相同的 ViewController。 我可以这样做吗?如果我在 tabBar 项中指定 ViewController 的 NIB,则会出现错误。

你能帮我吗?
提前致谢。

I've developed a ViewController that shows different data according to the input parameter. I would like to use a tabBar interface and call the same ViewController from different tabs by passing them to different parameters.
Can I do this? I get errors if I specify the ViewController's NIB in tabBar item.

Can you help me please?
Thanks in advance.

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

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

发布评论

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

评论(1

孤千羽 2024-10-02 16:44:43

创建 ViewController 的两个不同实例:

MyViewController *vc1 = [[MyViewController alloc] initWithNib:@"MyViewController" bundle:nil];
MyViewController *vc2 = [[MyViewController alloc] initWithNib:@"MyViewController" bundle:nil];

UITabBarController *tabs = [[UITabBarController alloc] init];
[tabs setViewControllers:[NSArray arrayWithObjects:vc1, vc2, nil] animated:NO];

Create two different instances of your ViewController:

MyViewController *vc1 = [[MyViewController alloc] initWithNib:@"MyViewController" bundle:nil];
MyViewController *vc2 = [[MyViewController alloc] initWithNib:@"MyViewController" bundle:nil];

UITabBarController *tabs = [[UITabBarController alloc] init];
[tabs setViewControllers:[NSArray arrayWithObjects:vc1, vc2, nil] animated:NO];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文