Uitabbarcontroller
Simple use of Uitabbarcontroller
First, the creation of Uitabbarcontroller (using code)
1. Create a new empty project in MJAPPDELEGATE.M's didfinishlaunch ... Method in
1. Create a Tabbar controller
Uitabbarcontroller *TABBARVC = [[Uitabbarcontroller alloc] init];
2. The root controller set to window
Self.window.rootViewController = TABBARVC;
3. Adding a child controller
Uiviewcontroller *VC1 = [[Uiviewcontroller alloc] init];
Vc1.view.backgroundColor = [Uicolor Redcolor];
Vc1.tabBarItem.title = @ "Contact";
Vc1.tabBarItem.image = [UIImage imagenamed:@ "Tab_buddy_nor"];
Uiviewcontroller *VC2 = [[Uiviewcontroller alloc] init];
Vc2.view.backgroundColor = [Uicolor Bluecolor];
Vc2.tabBarItem.title = @ "dynamic";
Vc2.tabBarItem.image = [UIImage imagenamed:@ "Tab_qworld_nor"];
Uiviewcontroller *VC3 = [[Uiviewcontroller alloc] init];
Vc3.view.backgroundColor = [Uicolor Greencolor];
Vc3.tabBarItem.title = @ "Settings";
Vc3.tabBarItem.image = [UIImage imagenamed:@ "Tab_me_nor"];
Tabbarvc.viewcontrollers = @[vc1,vc2,vc3];
[Self.window makekeyandvisible];
PS: The selected state of the picture is automatically turned blue, do not do it yourself.
Uitabbarcontroller View structure (note that the height of the Tabbar is 49)
PS: When you click on the leftmost side, display VC1 view, click in the middle, first move the VC1 view (not destroyed), and then put the VC2 view, unless a memory warning occurs to destroy the currently unused view
Uitabbar
Uitabbarbutton
Ii. creation of Uitabbarcontroller (using storyboard)
1. Come to storyboard, remove the default controller view and drag a tabbarcontroller. Remove the two controller view that is connected to the line and remove the line. Drag 3 Viewcontroller.
2. Delete the default controller file, create a new 3 controller file, and modify the class corresponding to the 3 Viewcontroller in storyboard.
3. Come to storyboard, right-click Tabbarcontroller, and connect the view controllers sequentially to the newly-dragged Viewcontroller.
4. Select the 3 viewcontroller buttons separately and modify the title
iOS Foundation-uikit framework-Multi-controller management-uitabbarcontroller