gpt4 book ai didi

ios - 无法将第二个选项卡栏添加到选项卡栏 Controller View

转载 作者:行者123 更新时间:2023-11-29 03:26:32 25 4
gpt4 key购买 nike

我试图在选项卡栏 Controller 的第一个 View 的顶部添加第二个选项卡栏,但由于某种原因,它控制了底部的选项卡栏并将所有内容添加到第一个选项卡按钮。我看不出我做错了什么,任何帮助将不胜感激。

MainViewController *controller = self.storyboard.instantiateInitialViewController;

//************ Add Tab Bar ***********************************
self.tabsController = [[SGTabsViewController alloc] init];
self.tabsController.delegate = self;
self.window.rootViewController = self.tabsController;

[self.tabsController setToolbarHidden:NO animated:NO];

[self.tabsController addViewController:controller];

double delayInSeconds = 3.;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self.tabsController setToolbarHidden:NO animated:YES];
});

self.textTabField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 240.0, 30.0)];
self.textTabField.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.textTabField.backgroundColor = [UIColor whiteColor];
self.textTabField.borderStyle = UITextBorderStyleRoundedRect;
self.textTabField.text = @"http://www.google.com";
self.textTabField.clearButtonMode = UITextFieldViewModeAlways;
self.textTabField.keyboardType = UIKeyboardTypeURL;
self.textTabField.autocorrectionType = UITextAutocorrectionTypeNo;
self.textTabField.delegate = self;


UIBarButtonItem *urlBar = [[UIBarButtonItem alloc] initWithCustomView:self.textTabField];

UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil action:nil];
UIBarButtonItem *reload = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self action:@selector(reload:)];
UIBarButtonItem *add = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self
action:@selector(add:)];


self.tabsController.toolbarItems = [NSArray arrayWithObjects:space,urlBar,space,reload,add,nil];
self.tabsController.title = @"Loading...";

enter image description here

最佳答案

创建标签栏成功后,请将 Root View 设置为窗口中的标签栏。像一样

    ViewController1 checkinPage=[[ViewController1 alloc]initWithNibName:@"ViewController1" bundle:nil];
checkinPage.tabBarItem.title = @"Check In";
checkinPage.tabBarItem.tag=1;
checkinPage.tabBarItem.image = [UIImage imageNamed:@"tab_ic_CheckIn.png"];

ViewController2 incentive=[[ViewController2 alloc] initWithNibName:@"ViewController2" bundle:nil];
incentive.tabBarItem.title=@"Incentives";
incentive.tabBarItem.tag=2;
incentive.tabBarItem.image=[UIImage imageNamed:@"tab_ic_Incentives.png"];
.tabBarItem.title = @"Check In";

self.tabsController.viewControllers = [NSArray arrayWithObjects:checkinPage,incentive,nil];

self.tabBar.selectedIndex=1;

self.window.rootViewController = self.tabsController;

所以请确保标签栏的创建并将它们添加到正确的位置。

关于ios - 无法将第二个选项卡栏添加到选项卡栏 Controller View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20391502/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com