导航后获取 tabbarcontroller

发布于 2024-12-29 17:15:58 字数 431 浏览 0 评论 0原文

我有一个带有按钮的视图控制器,单击该按钮后应该会出现 tabbarcontroller。如何以编程方式执行此操作。?

我发现的所有教程在应用程序启动后立即显示选项卡栏。但我希望它在单击按钮并导航到另一个视图后可见。

我编写了用于导航到新页面的代码,以便新页面应包含选项卡栏控制器。

-(IBAction)buttonClicked
{

 ViewController *viewController = [[ViewController alloc]initWithNibName:@"view" bundle:nil];
        [self.navigationController pushViewController:viewController animated:YES];
        [viewController release];
}

I have a view controller with a button and after clicking that button tabbarcontroller should appear.how to do it programatically.?

all the tutorials i found show tab bar immediately once the app is started.but i want it to be visible after the button is clicked and navigated to the other view.

i wrote code for navigating to a new page so that new page should consist of tab bar controller.

-(IBAction)buttonClicked
{

 ViewController *viewController = [[ViewController alloc]initWithNibName:@"view" bundle:nil];
        [self.navigationController pushViewController:viewController animated:YES];
        [viewController release];
}

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

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

发布评论

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

评论(2

世界如花海般美丽 2025-01-05 17:15:58

尝试这样的事情:

-(IBAction)buttonClicked
{
    UITabBarController *tabBarController = [[UITabBarController alloc] init];
    UIViewController *vc1 = [[UIViewController alloc] initWithNibName:@"VC1" bundle:nil];
    UITabBarItem *tbi1 = [[UITabBarItem alloc] initWithTitle:@"VC1" image:[UIImage imageNamed:@"vc1"] tag:1];
    vc1.tabBarItem = tbi1;
    // more viewControllers here

    tabBarController.viewControllers = [NSArray arrayWithObjects:vc1, vc2, vc3, nil];
    [self.navigationController pushViewController:tabBarController animated:YES];
}

Try something like this:

-(IBAction)buttonClicked
{
    UITabBarController *tabBarController = [[UITabBarController alloc] init];
    UIViewController *vc1 = [[UIViewController alloc] initWithNibName:@"VC1" bundle:nil];
    UITabBarItem *tbi1 = [[UITabBarItem alloc] initWithTitle:@"VC1" image:[UIImage imageNamed:@"vc1"] tag:1];
    vc1.tabBarItem = tbi1;
    // more viewControllers here

    tabBarController.viewControllers = [NSArray arrayWithObjects:vc1, vc2, vc3, nil];
    [self.navigationController pushViewController:tabBarController animated:YES];
}
九公里浅绿 2025-01-05 17:15:58

从“单一空视图”项目开始。
然后只需添加一个新的 UITabBarController (在我的脑海中)

UITabBarController *tbc = [[UITabBarController alloc] init] autorelease];
[tbc.view setFrame:self.view.bounds];
[tbc setViewControllers:[NSArray arrayWithObjects: viewController1, viewController2, viewController3, nil]];
[self.view addSubview:tbv.view];

然后你必须在 tabBarItem 属性中的相应 viewController 中设置标题和图标: http://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/tabBarItem

Start of with a 'single empty view' project.
Then just add a new UITabBarController (out the top of my head)

UITabBarController *tbc = [[UITabBarController alloc] init] autorelease];
[tbc.view setFrame:self.view.bounds];
[tbc setViewControllers:[NSArray arrayWithObjects: viewController1, viewController2, viewController3, nil]];
[self.view addSubview:tbv.view];

Then you have to set the title and icon in the corresponding viewControllers in the tabBarItem property: http://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/tabBarItem

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