Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use folding tab bar on none root view controller? #18

Closed
MarceloPrado opened this issue Jun 30, 2015 · 9 comments
Closed

How to use folding tab bar on none root view controller? #18

MarceloPrado opened this issue Jun 30, 2015 · 9 comments

Comments

@MarceloPrado
Copy link

Hello, how are you doing today?
I'm trying to set YALFoldingTabBarController on specific view controller inside App Delegate, but it doesn't work (tab bar doesn't show up). It is possible to use this tab bar outside root view controller? How?
Thanks!

@scoobydont
Copy link

I was stuck on this for a bit but this is how I got it to work:

First, in your main storyboard, make a new UITabBarController. Next, add a new Cocoa Touch Class file to your project and make sure it is a subclass of YALFoldingTabBarController. Whatever you end up naming it, go back to the main storyboard and set the class name of the UITabBarController you made earlier to the name you gave to the Cocoa Touch Class file you created.

Next, in the new class file you made in the viewDidLoad function, you would set up all the same things you see in the AppDelegate file in the example provided by Yalantis minus this statement:

YALFoldingTabBarController *tabBarController = (YALFoldingTabBarController *) self.window.rootViewController;

Then, everytime you see tabBarController used, you would simple use "super" instead. This worked for me using swift so the SampleFoldingTabBarController.swift file (which is the custom Cocoa Touch Class I made) looks something like this:

import UIKit
import FoldingTabBar

class SampleFoldingTabBarController: YALFoldingTabBarController {

let tabItem1: YALTabBarItem = YALTabBarItem(itemImage: UIImage(named:"something", leftItemImage: UIImage(named:"somethingElse")

override func viewDidLoad() {

    super.viewDidLoad()

    super.leftBarItems = [tabItem1]

    super.centerButtonImage = UIImage(named: "centerImage")

    //so on and so forth

}

@serejahh
Copy link
Contributor

@MarceloPrado Have you tried the solution above? Do you need some help?

@alexrodrigues
Copy link

It works!!! Thanks

@LiveRock
Copy link

LiveRock commented May 19, 2016

It works! But I also want to handle touches on extra tabBarItems in the items page. So far, no successes after 2 days...

`import Foundation
import UIKit
import ARSLineProgress
import FoldingTabBar

class ViewControllerHome: UIViewController,UITextFieldDelegate,YALTabBarInteracting,YALTabBarViewDelegate {

var delegate: YALTabBarViewDelegate?

override func viewDidLoad() {
    super.viewDidLoad()
    print("Home VC called")
    // Do any additional setup after loading the view.


  //  tabBarController = (YALFoldingTabBarController *) self.window.rootViewController

}

// MARK: YALTabBarInteracting protocol
@objc func extraLeftItemDidPressInTabBarView(tabBar: YALFoldingTabBar) {
    print("extraLeftItemDidPressed")

}

@objc func extraRightItemDidPressed(sender: AnyObject) {
    print("extraRightItemDidPressed")

}

}`

@LiveRock
Copy link

Ok, i got it.

@hungri-yeti
Copy link

@LiveRock Can you give some guidance how you did this?

@LiveRock
Copy link

First, you need to conform to the protocol YALTabBarInteracting
Then you need to implement extraLeftItemDidPress and extraRightItemDidPress like this:

// MARK: YALTabBarInteracting protocol
@objc func extraLeftItemDidPress() {
print("extraLeftItemDidPress")
}

I couldn't get it to work initially because I did not implement it properly like:
@objc func extraLeftItemDidPress(sender : AnyObject!) {
print("extraLeftItemDidPress")
}

@tambadiya
Copy link

I am ios developer..
i want to use folding tabbar in only one view controller so its possible for use it..?

@ilhammalik
Copy link

i want implement for swift, some people can help me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants