Ways to resolve custom Tabbar jump hiding problems in iOS

Source: Internet
Author: User

in theiOS development (http://www.maiziedu.com/course/ios/) , how to customize the Tabbar height of the jump hiding problem, For example, and the system comes with the tabbar height is not the same as the result of a line problem, there are push animation effect and so on some column problem not here, of course, there are many ideas, can refer to the above link himself pondering, well, the following directly on the individual think the perfect solution.

Demand1, custom tabbar, without the tabbar of the system 2, the 2nd requirement is the height of the custom Tabbar and the system is different, the system tabbar height of This is why the third requirement has multiple solutions. 3, jump hide tabbar, this demand is very simple, but in the premise of the second demand is not so easy to achieve the third requirement.

Perfect Solution (write-only key code)Custom Tabbar

Create a custom Tabbar andset frame(frame is dead, readers can change according to their own needs, The author uses a custom high of.

Ertabbar *tabbar = [[Ertabbar alloc] initWithFrame:CGRectMake(0, 0,  the,  -)];

set The height of the system Tabbar (other blogs or forums are resolved as well)

CGRectframe = [UIScreenmainscreen].bounds; Self. Tabbar.frame =CGRectMake(0, Cgrectgetheight(frame)-44, Cgrectgetwidth(frame), -);UIView*transitionview = [[ Self. View Subviews] Objectatindex:0];

frame.size.height = Cgrectgetheight (frame)- - ;

Transitionview.frame = frame;

Add custom tabbar to the Tabbar of the system

[Self.tabbar Addsubview:tabbar] ;

Remove the system's own Tabbarbutton in the viewwillappear method

-(void) viewwillappear: ( BOOL ) Animated

{

[Super viewwillappear:animated];

// Delete the system's own Tabbarbutton

     for (UIView*tabbarbuttoninch  Self. Tabbar.subviews) {

        if([Tabbarbutton iskindofclass:nsclassfromstring(@ "Uitabbarbutton")]) {

[Tabbarbutton Removefromsuperview];

}

}

}

Jump Hide

- (void) Pushviewcontroller: (Uiviewcontroller*) Viewcontroller animated: (BOOL) Animated

{ if   ( self . Childviewcontrollers.count)  {  //  not the root controller

viewcontroller.hidesbottombarwhenpushed = YES ;

[super Pushviewcontroller:viewcontroller animated:animated];

}


How to troubleshoot custom Tabbar jump hiding problems in iOS

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.