handsomecode / InteractiveSideMenu

iOS Interactive Side Menu written in Swift.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

side menu on tabbar only I am facing problem

shaharukhs opened this issue · comments

Hello

My home viewcontroller has tab bar when I try to push any viewcontroller from side menu then tab bar is getting hidden or not able to see.

I am new to swift and just for practice I am tried to implement this.

here you can find my repository if you want to know what I have done.

Thank you in advance.

Hi @shaharukhs,

It looks like not right ViewControllers adopt SideMenuItemContent protocol.
TabBarViewController itself should do it:

class TabBarViewController: UITabBarController, SideMenuItemContent {
}

class FirstViewController: UIViewController {

    @IBAction func openMenu(_ sender: UIButton) {
        if let menuItemViewController = self.tabBarController as? SideMenuItemContent {
            menuItemViewController.showSideMenu()
        }
    }
}

class SecondViewController: UIViewController {

    @IBAction func openMenu(_ sender: UIButton) {
        if let menuItemViewController = self.tabBarController as? SideMenuItemContent {
            menuItemViewController.showSideMenu()
        }
    }
}

Please, check the Sample for more details. TabBarController is implemented there.

Also, README should help you with TabBar and Navigation controllers.

Thank you for your question, good luck in iOS development!

You can use swipe gesture to show side menu and yes I know menu button is not working as you said.

So, the question - why menu button is not visible on this screen https://cl.ly/0d0x34440n2f?

Could you formulate your question again, please? TabBar is not hidden in current version of your code.

Hi @shaharukhs again,

I've reproduced your issue. The problem is that you push TabBarController via selectContentViewController method:

let viewController = self.storyboard?.instantiateViewController(withIdentifier: "TabBar")
self.selectContentViewController(viewController!)

and then use FirstViewController and SecondViewController as menu items:

let controllersIdentifiers = ["first", "second"]

What do you want to get: TabBar as one of Menu Items or TabBar together with Side Menu (side menu items will duplicate tab bar items)?

What I want is if I select any of side menu item then tab bar should not hidden.

Just like tabBarController?.selectedIndex = 0 or 1

But if I try to pushViewController its hidden.

Hope you understand what I want to say.

step 1. Tab bar is showing.
simulator screen shot 23-jun-2017 12 59 08 pm

step 2. select any item from side menu
simulator screen shot 23-jun-2017 12 59 13 pm

step 3. this is my problem. Tab bar gone.
this is what happen when side menu item select tab bar gone

Hi Shahrukh,

Yes, now I understand your question. You are going to implement SideMenu that will duplicate TabBar's items. It's quite seldom case and our library doesn't support this from the box. But I can describe the steps, how you can try to implement your idea:

  1. Please, note, that method selectContentViewController should push one of the Menu Items, not another controller. Now in your implementation it pushes TabBar and then, when user chooses items, you push First or Second view controllers. It's not right way. You should select one of these view controllers in the beginning.

  2. To implement your idea you should always use your TabBar as ContentViewController and switch between TabBar items, when SideBarMenu items are clicked. Unfortunately, I didn't have enough time to check this idea, but it should work. Will try to do this later.

In general, it's awesome idea to have opportunity to create SideBarMenuContent from the ChildViewController, not full screen. Big thanks for that! We will think about this feature.

Hi @shaharukhs,

I've updated a Sample to implement desired behavior: https://cl.ly/2y1y2B0S2P2o.
You can find a zip here.

You shouldn't select a new controller every time. You always have to use TabBar.

Save tabBarViewContoller as a property of HostViewController:

self.tabBarViewController = self.storyboard?.instantiateViewController(withIdentifier: "TabBar") as? UITabBarController 
self.selectContentViewController(tabBarViewController!)

Add selectTab func implementation:

func selectTab(_ index: Int) { 
    tabBarViewController?.selectedIndex = index 
}

On tableView's item click in NavigationMenuViewController you should call this method instead of selecting ViewController as new SideMenu item.

if let hostViewController = menuContainerViewController as? HostViewController { 
    hostViewController.selectTab(indexPath.row) 
}
menuContainerViewController.hideSideMenu()

Hope, it'll be helpful.
Please, have fun using InteractiveSideMenuLibrary!

Hi @shaharukhs ,
i'm getting the same problem as you faced in past. If have any solution to that then do share with me bcz i searched every where but didn't anything. i'm mentioning my problem below:
On selecting menu Item from the burger menu TabBar gets disappear ?

I have burger button (menu button) in almost all vc and my main screen is tabBarController. Currently I'm getting the side menu when tapping on the Button .On choosing a menu, it shows the desired vc but the bottom tab bar is not there which was there before i select menu item. I want to have the bottom tabbar in entire pages also in pages from the side menu. I.'m using SWRevealViewController for burger menu

How can I acheive this? Please help me.

The code I'm using in didSelectRowAtIndexPath is:

if indexPath.row == 1 {
let vc = storyboard?.instantiateViewController(withIdentifier: "FeedScreenVC") as! FeedScreenVC
let nav = UINavigationController.init(rootViewController: vc)
self.revealViewController().pushFrontViewController(nav, animated: true)
}