Ios Can';t将第二个选项卡栏添加到选项卡栏控制器视图
我试图在选项卡栏控制器的第一个视图的顶部添加第二个选项卡栏,但出于某种原因,它控制了底部的选项卡栏,并将所有内容添加到第一个选项卡按钮。我看不出我做错了什么,任何帮助都将不胜感激Ios Can';t将第二个选项卡栏添加到选项卡栏控制器视图,ios,iphone,tabs,uitabbarcontroller,Ios,Iphone,Tabs,Uitabbarcontroller,我试图在选项卡栏控制器的第一个视图的顶部添加第二个选项卡栏,但出于某种原因,它控制了底部的选项卡栏,并将所有内容添加到第一个选项卡按钮。我看不出我做错了什么,任何帮助都将不胜感激 MainViewController *controller = self.storyboard.instantiateInitialViewController; //************ Add Tab Bar *********************************** self.tabsCont
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...";
成功创建选项卡栏后,请在窗口中将根视图设置为选项卡栏。像
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;
因此,请确保选项卡栏的创建,并将它们添加到正确的位置