如何处理视图控制器?

发布于 2024-11-08 16:18:33 字数 178 浏览 2 评论 0原文

大家好,我正在开发一个应用程序。那里有一个带有 5 个按钮的主屏幕。单击每个按钮时,我想打开带有带有 5 个视图控制器的选项卡栏的屏幕。我的意思是,当您单击按钮时,选项卡栏将打开。标签栏视图上也有后退按钮。单击后退按钮时,我想弹回到主屏幕,反之亦然。 如何做到这一点,伙计们。任何教程、链接、示例代码将不胜感激。

非常感谢大家

Hi guys I am working on an application.Where there is a home screen with 5 buttons.On the click of every button i want to open the screen with tabbar with 5 view controllers.I mean when you click on the button the tabbar is opened.And there are back button on the tab bar view as well .On clicking the back button i want to pop back to the home screen and vice versa.
How to do that guys.Any tutorial ,links,sample code would be appreciated.

Thanks a lot to all

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

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

发布评论

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

评论(1

小清晰的声音 2024-11-15 16:18:33

导航堆栈中的选项卡栏控制器很复杂。由于每个选项卡控制器本身也可以有导航控制器。

有一个 WindowManager 类。它应该同时拥有
- FirstViewController 和
- TabbarController

所有组件和 UITabbarController 本身都应该在 WindowManager 类中实例化。
它的 init 可能有这样的代码,对于两个 tabbarcontroller 来说类似。

self.tabBarController = [[UITabBarController alloc] init];
    self.controllers = [[NSMutableArray alloc] init];

// initialize the view controllers and navigation controllers for the tab bar

self.friendsVC = [[FriendsVC alloc] initWithNibName:@"FriendsView" bundle:nil];
UINavigationController *friendsNVC = [[UINavigationController alloc] initWithRootViewController: friendsVC];
friendsNVC.navigationBar.barStyle = UIBarStyleBlack;
[controllers addObject:friendsNVC];  
[friendsNVC release];

self.paymentsVC = [[PaymentsVC alloc] initWithNibName:@"PaymentsView" bundle:nil];
UINavigationController *paymentsNVC = [[UINavigationController alloc] initWithRootViewController: paymentsVC];
paymentsNVC.navigationBar.barStyle = UIBarStyleBlack;
[controllers addObject:paymentsNVC];
[paymentsNVC release];  

tabBarController.viewControllers = controllers;
tabBarController.selectedIndex = 0; 
tabBarController.delegate = self;

self.view = tabBarController.view;

在 WindowManager 中,您可以有两种方法,例如,

[WindowManager showViewController] and
[WindowManager showTabbarController].

- showViewController {
  //Initiate View controller and use [self.window addSubView:vc.view];
}

- showTabbarController {
  // initiate the tabbar manager
}

您可以在第一个选项卡栏控制器左侧顶部有一个“后退”按钮,以调用

[WindowManager showViewController];

Tabbar controller in a navigation stack is complicated. Since each tab controller can have also navigation controller itself.

Have a WindowManager class. It should own both
- FirstViewController and
- TabbarController

All components and the UITabbarControllers themselves should be instantiated in the WindowManager class.
Its init may have code like this, make similar for two tabbarcontrollers.

self.tabBarController = [[UITabBarController alloc] init];
    self.controllers = [[NSMutableArray alloc] init];

// initialize the view controllers and navigation controllers for the tab bar

self.friendsVC = [[FriendsVC alloc] initWithNibName:@"FriendsView" bundle:nil];
UINavigationController *friendsNVC = [[UINavigationController alloc] initWithRootViewController: friendsVC];
friendsNVC.navigationBar.barStyle = UIBarStyleBlack;
[controllers addObject:friendsNVC];  
[friendsNVC release];

self.paymentsVC = [[PaymentsVC alloc] initWithNibName:@"PaymentsView" bundle:nil];
UINavigationController *paymentsNVC = [[UINavigationController alloc] initWithRootViewController: paymentsVC];
paymentsNVC.navigationBar.barStyle = UIBarStyleBlack;
[controllers addObject:paymentsNVC];
[paymentsNVC release];  

tabBarController.viewControllers = controllers;
tabBarController.selectedIndex = 0; 
tabBarController.delegate = self;

self.view = tabBarController.view;

In the WindowManager, you can have two methods like,

[WindowManager showViewController] and
[WindowManager showTabbarController].

- showViewController {
  //Initiate View controller and use [self.window addSubView:vc.view];
}

- showTabbarController {
  // initiate the tabbar manager
}

You can have a "back" button on top of your first tabbar controller left side, to call the

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