我在我的项目中使用了SWRevealviewcontroller
。起初我把viewcontroller
命名为" SWREVEALVIEWController "并将sw_rear
设置为tableviewcontroller
。在sw_front
部分,我设置了TabbarViewcontroller
。
现在我的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项目。
看屏幕。第一个屏幕是
单击侧面菜单单元格后,例如单击home,主视图控制器打开但没有其tabbar项目。怎么解决这个?
之后,swRevealviewcontromller
的滑动按钮在通过单击单元格菜单返回任何viewcontroller
后无法正常工作...... ????
答案 0 :(得分: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)
我没有测试这个
答案 1 :(得分:0)
在SW_front ViewController中添加此代码
-(void)viewWillAppear:(BOOL)animated{
if revealViewController() != nil {
menuButton.target = revealViewController()
menuButton.action = "revealToggle:"
view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
答案 2 :(得分:0)
let controller = self.storyboard?.instantiateViewController(withIdentifier: "YourControllerIndentifire")
let nc = UINavigationController(rootViewController: controller!)
revealViewController()?.pushFrontViewController(nc, animated: true)