The Hidden Uitabbar of "original" iOS learning

Source: Internet
Author: User

When the page uses the Uitabbarcontroller + uinavigationcontroller frame, when jumping to the detail page, if the Uitabbar still exists, it will cause the logic confusion, the user experience will be reduced, So we have one in the details page will uitabbar hidden requirements, of course, in some other cases may also have hidden uitabbar needs, here Small series for you to introduce three kinds of hidden uitabbar methods, we can choose according to the detailed needs.

1. The first kind:

 Hide the Uitabbar of the current page directly

// show TabBarself.tabBarController.tabBar.hidden = NO; // Hide TabBarself.tabBarController.tabBar.hidden = YES;

2. The second type:

 Hides the uitabbar of the page being push to

// hide Tabbar on push jump New  = yes;[ VC1 PUSHVIEWCONTROLLER:VC2 Animated:yes];

This method in the jump page when used, according to its name can be found in the push jump or modal jump when it will take effect, that is, Uitabbarcontroller and uinavigationcontroller in combination with the use of the time, You can use the modal jump page.

This is the small sub-series in the beginning of the kind of situation mentioned, small people think is also a more commonly used situation!

3. The third type:

Do not use the existing system-provided methods, custom methods, modify TabBar's subview frame on the line.

Principle:

There are two subview in Uitabbarcontroller, one called Uitabbar, the bar below, and the other called Uitranstionview, which is the view above bar. There are other subview under the two view, so don't worry about it. Move the Uitabbar y down by 49 units, and Uitranstionview the hight to 49 units longer.

Code Listing 1:

- (void) Hidestabbar: (BOOL) hidden{[UIView Beginanimations:nil context:null]; [UIView setanimationduration:0];  for(UIView *viewinchself.tabBarController.view.subviews) {if([View Iskindofclass:[uitabbarclass]]) {             if(hidden) {[View Setframe:cgrectmake (view.frame.origin.x, [UIScreen mainscreen].bounds.size.height, V                             Iew.frame.size.width, View.frame.size.height)]; }Else{[View Setframe:cgrectmake (view.frame.origin.x, [UIScreen mainscreen].bounds.size.height- the, View.frame.size.width, View.frame.size.height)]; }         }Else{             if([View iskindofclass:nsclassfromstring (@"Uitransitionview")]){                 if(hidden) {[View Setframe:cgrectmake (view.frame.origin.x, VIEW.FRAME.ORIGIN.Y, View.frame.size.wi                                      DTH, [UIScreen mainscreen].bounds.size.height)]; }Else{[View Setframe:cgrectmake (view.frame.origin.x, VIEW.FRAME.ORIGIN.Y, View.frame.size.width, [Uisc Reen mainscreen].bounds.size.height- the )];      }}}} [UIView commitanimations]; }

Code Listing 2:

-(void) Maketabbarhidden: (BOOL) Hide {//Custom code to hide TabBar    if([Self.tabBarController.view.subviews Count] <2 )    {        return; } UIView*contentview;if([[Self.tabBarController.view.subviews Objectatindex:0] Iskindofclass:[uitabbarclass]]) {Contentview= [Self.tabBarController.view.subviews Objectatindex:1]; } Else{Contentview= [Self.tabBarController.view.subviews Objectatindex:0]; }    if(hide) {contentview.frame=Self.tabBarController.view.bounds; } Else{contentview.frame=CGRectMake (self.tabbarcontroller.view.bounds.origin.x, SELF.TABBARCONTROLLER.VIEW.BOUNDS.ORIGIN.Y, Self.tabBarController.view.bounds.size.width, Self.tabBarController.view.bounds.size.height-self.tabBarController.tabBar.frame.size.height); } Self.tabBarController.tabBar.hidden=Hide;}

The above is a summary of the three ways, but also from the Great God's blog summary, if there is any new method, welcome to discuss together!

The Hidden Uitabbar of "original" iOS learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.