Git Product home page Git Product logo

mhcustomtabbarcontroller's Introduction

MHCustomTabBarController

Join the chat at https://gitter.im/mhaddl/MHCustomTabBarController

MHCustomTabBarController is a customizable UITabBarController replacement using Storyboard and segues. It's built with Apples Custom Container ViewController API and so requires iOS 6+.

Setup

Have a look at the demoporject and do the following steps.

Create your Custom TabBarController

Insert a UIViewController into your storyboard and set the class to "MHCustomTabBarController". Place a UIView (your "UITabBar") into the ViewController. Add UIButtons (your "UITabBarItems") to the view (the buttons must IN the UIView). Add a Container View above (or where you want) to the ViewController.

Hook up the outlets

Hook up the outlets in MHCustomTabBarController with your created views in the storyboard.

@property (weak, nonatomic) IBOutlet UIView *container;
@property (nonatomic) IBOutletCollection(UIButton) NSArray *buttons;

Create your ContentViewControllers

Place your desired ViewControllers into the storyboard and connect them with a UIButton in the CustomTabBarController. Give the created segues identifiers matching this scheme:

  • initial, first ViewController = "viewController1"
  • second ViewController = "viewController2"
  • ...

Set the style of the segues to "custom" and the class to "MHTabBarSegue".

License

The MIT License (MIT)

Copyright (c) 2015 Martin Hartl

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

mhcustomtabbarcontroller's People

Contributors

gitter-badger avatar hartlco avatar mchinyakov avatar mikeabdullah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mhcustomtabbarcontroller's Issues

Slow performance

When I press a tab, the first time a view gets loaded, it takes some time. Any Idea on why that could happen?

Thank you very much!

Filter by Subview Type

It appears that you parse through the view that holds the buttons and look for subviews, and wire them up as the tabs.

It would be cool if you altered this slightly so that it only uses subview of type UIButton. That way I can include images and other views in my button container as needed. :)

Thanks!

viewController1 should be configurable

It doesn't make sense to say to change this in your class since if you use this as a cocoapod, you're not going to want to change your class. I think "viewController1" should be configurable in another way. Perhaps by subclassing

How to hide MHCustomTabBarController on particular ViewController

Hello Mhaddl!
Hope you are doing good.

I have a view with your controller. It is not working same as UITabBarController. As Like UITabBarController We can hide this on some UIViewController while pushing or presenting it modally. How can we achieve this with your controller? Do you have any valuable suggestion?
Thanks-
Ashutosh Mishra

New Release (Pods)

Please do a new release (for pods) with the latest changes.

MHCustomTabBarController.h:
viewDidAppear --> viewWillAppear

Error when using on Storyboard

Im trying to use this component in my project, but when I reach in my navigation this container, I get an app crash with this error:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIStoryboardSegueTemplate 0x7fa2b346ebd0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key containerView.'

It was working fine in the demo project, I copied from one storyboard to another and then I got the Crash...

What am I missing?

Pod Install Error for iOS Version

In your Readme, you state that iOS 5+ is required. But when I attempt to install the Pod, I get the following error:

[!] The platform of the target 'Pods' (iOS 5.0) is not compatible with 'MHCustomTabBarController (1.0.1)' which has a minimum requirement of iOS 6.0.

Any ideas?

Button Set Selected

Hi, i found a bug i think. When i press a button and then i press another one the first one remain selected. In a tabbar only the last pressed should be selected. How can i fix this? Thanks.

Setting text to buttons?..

Hello
For some reason I'm unable to set text to buttons in subclass (see my pull request #26, where I expose this property)

// does not work eg. in - (void)viewWillAppear:(BOOL)animated
- (void)viewDidLayoutSubviews
{
    UIButton *btn = self.buttons[0];
   [btn setTitle:@"TESTING" forState:UIControlStateSelected | UIControlStateNormal | UIControlStateHighlighted]; // does not work
    btn.backgroundColor = [UIColor redColor]; // works
    btn.titleLabel.text = @"TEST"; // works, but flickering
}

Pods issue from version 1.2 to latest updated

I was using 1.2 version but recently when i run pod update, I am getting following issues in new repo

  1. I am getting 5 errors like buttons are unknown class methods. previosuly you declared in .h class but now you are using it by interface methods. also I made changes in framework code.
    2)Crash on viewWillAppear , you changed the code ViewDidAppear to ViewWillApper

I can make changes in framework and get my code run but that should not be a good practise.

Can you please suggest a way ?

thanks in advance.

More than one MHCustomTabController

Hello, is it possible to have more than one MHCustomTabController in an app? I'm struggling with that but it's not working, something to do with the segue names convention maybe?

Sizing issue

Hey, first off - great library!

I seem to be experiencing an issue when I load up on first run there's a noticeable gap at the top of my view.

screen shot 2013-08-29 at 14 13 33

If i switch to a different tab and then come back - it works as expected.
And if I change this code

  • (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    if (self.childViewControllers.count < 1) {
    [self performSegueWithIdentifier:@"viewController1" sender:[_buttonView.subviews objectAtIndex:0]];
    }
    }

to this

  • (void)viewDidLayoutSubviews {
    double delayInSeconds = 0.0;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
    [super viewDidLayoutSubviews];
    if (self.childViewControllers.count < 1) {
    [self performSegueWithIdentifier:@"viewController1" sender:[self.buttonView.subviews objectAtIndex:0]];
    }
    });
    }

It also works as expected.
The only issue is that I'm using CocoaPods and the only good way to make that change is to include a category on your class.

Any ideas about a cleaner workaround?

Thanks

didReceiveMemoryWarning

Isn't your current didReceiveMemoryWarning redundant with what you do in your segue?
Shouldn't you rather clean the cache?

presentingViewController ?

Hi Martin,

In your viewWillAppear, viewDidAppear, viewWillDisappear, viewDidDisappear methods. Why do you send the message to self.presentingViewController ?

Normally, they're sent to the child view http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html

Alternatively, the methods can be empty since UIViewController automatically forward rotation and appearance methods (see shouldAutomaticallyForwardAppearanceMethods and shouldAutomaticallyForwardRotationMethods).

Cheers,
d.

controller changes while switching between tabs

Hello, I am having issue like i cant get the lastviewcontroller when i get back to the tab. It starts from the root . It doesnt work like tabbar. Can we get that functionality where we can double tap on tab and then get the rootviewcontroller inspite of just one click. I am using storyboard.

selectedViewController and selectedIndex

Hi, @mhaddl
I like this lib because I always use navigationController as the initial viewcontroller in storyboard and TabBarController as the second, because that would save works for animating hiding tabBar. But this would be more convinient if we support selectedViewController and selectedIndex function as UITabBarController, wouldn't it?

Sizing issue when calling first controler in viewDidAppear

Hi,
I´v used your code in my app and figured out that, if you call the segue for the first controller in the viewDidAppear, there are layout issues occuring with auto layout.

How to reproduce:

Use autolayout.
Build a view containing two View containers side by side. (Somehow a custom SplitView)
Now in the right one display the MHTabBarController be using a push segue + set the width of the left one to 0 (using a property representing the corresponding constraint.

What happens:

MHTabBarController calls the segue for it´s initial tab to late.
The left container, no longer being as wide as before, causes the right one to expand to full screen width.
Unfortunately the initial view controller (tab) does not resize properly (stays on initial wide of is parent container view), only after switching to the second tab and back to first one the layout is proper.

Proposed solution (working for me):

Do not call for the segue to the initial tab (viewController1) in viewDidAppear but instead move the code to viewWillAppear. This ensures autolayout is working properly for the inital tab when MHTabBarController gets opened.

Took me some time to figure it out... nasty auto layout ;-). Hope this helps.
Regards,
Oggerschummer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.