Pradip Kumar Pradip Kumar - 4 months ago 32
Swift Question

how to resolve the swrevealviewcontroller issue

I have used

SWRevealviewcontroller
in my project. At first I took a
viewcontroller
named it "SWREVEALVIEWController" and set the
sw_rear
to a
tableviewcontroller
. And in the
sw_front
part I set a
TabbarViewcontroller
.

enter image description here

Now I have the few row data in my
tableview
which i set as
sw_rear
.

menuArray = ["HOME","ORDER NOW","PHOTOS","REVIEWS","FEEDBACK","RATE US","LOGIN"]


And clicking on each particular cell i set it to the appropriate viewcontroller like this.

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
switch(indexPath.row)
{
case 0 :
print("1st row")
//self.performSegueWithIdentifier("Main", sender: self)
let mainStoryboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
let vc : UINavigationController = mainStoryboard.instantiateViewControllerWithIdentifier("home") as! UINavigationController
self.presentViewController(vc, animated: true, completion: nil)


case 1 :
print("2nd row")
let mainStoryboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
let vc : UINavigationController = mainStoryboard.instantiateViewControllerWithIdentifier("menuVC") as! UINavigationController
self.presentViewController(vc, animated: true, completion: nil)


But After using this its going to the appropriate place but without its tabbar items.

see the screens . the first screen is

enter image description here

after clicking the side menu cells for example clicking on home the home viewcontrollers open but without its tabbar item. how to solve this??

enter image description here

enter image description here

And after that the sliding button for
swRevealviewcontromller
not working after returning back to any
viewcontroller
by clicking on cells menu...????

Answer

You need to use the pushFrontViewController method from SWRevealViewController to change your front view controller.

Example

self.revealViewController().pushFrontViewController(viewController, animated: true)

To push your TabbarViewcontroller, you should give it an identifier in the Storyboard. Then you can use

let sb = UIStoryboard(name: "Main", bundle: nil)
let vc = sb.instantiateViewControllerWithIdentifier("yourtabbarvcidentifier")
self.revealViewController().pushFrontViewController(vc, animated: true)

EDITED

To open a certain tab

let sb = UIStoryboard(name: "Main", bundle: nil)
let vc = sb.instantiateViewControllerWithIdentifier("yourtabbarvcidentifier") as! UITabBarController
vc.selectedIndex = 1 // Your index you want to open
self.revealViewController().pushFrontViewController(vc, animated: true)

I did not test this