如何解决swrevealviewcontroller问题

问题描述 投票:2回答:3

我在我的项目中使用过SWRevealviewcontroller。起初我拿了一个名为“SWREVEALVIEWController”的viewcontroller并将sw_rear设置为tableviewcontroller。在sw_front部分我设置了TabbarViewcontroller

enter image description here

现在我在我的tableview中有几个行数据,我设置为sw_rear

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

然后点击每个特定的单元格,我将它设置为适当的viewcontroller,就像这样。

 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)

但在使用它之后它会进入适当的位置,但没有它的tabbar项目。

看到屏幕。第一个屏幕是

enter image description here

单击侧面菜单单元格后,例如单击home,主视图控制器打开但没有其tabbar项目。怎么解决这个?

enter image description here

enter image description here

之后,swRevealviewcontromller的滑动按钮在单击细胞菜单返回任何viewcontroller后无法正常工作...... ????

ios swift xcode swrevealviewcontroller
3个回答
3
投票

您需要使用SWRevealViewController中的pushFrontViewController方法来更改前视图控制器。

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

要推送TabbarViewcontroller,您应该在Storyboard中为其指定一个标识符。然后你可以使用

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

EDITED

要打开某个标签页

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)

我没试过这个


0
投票

在SW_front ViewController中添加此代码

-(void)viewWillAppear:(BOOL)animated{
    
   if revealViewController() != nil {
        menuButton.target = revealViewController()
        menuButton.action = "revealToggle:"
        view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
    }

0
投票
 let controller = self.storyboard?.instantiateViewController(withIdentifier: "YourControllerIndentifire")
 let nc = UINavigationController(rootViewController: controller!)
 revealViewController()?.pushFrontViewController(nc, animated: true)
© www.soinside.com 2019 - 2024. All rights reserved.