我在我的项目中使用过SWRevealviewcontroller
。起初我拿了一个名为“SWREVEALVIEWController”的viewcontroller
并将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
后无法正常工作...... ????
您需要使用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)
我没试过这个
在SW_front ViewController中添加此代码
-(void)viewWillAppear:(BOOL)animated{
if revealViewController() != nil {
menuButton.target = revealViewController()
menuButton.action = "revealToggle:"
view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
let controller = self.storyboard?.instantiateViewController(withIdentifier: "YourControllerIndentifire")
let nc = UINavigationController(rootViewController: controller!)
revealViewController()?.pushFrontViewController(nc, animated: true)