SWRevealviewcontroller用于侧栏菜单。菜单包含主页,个人资料,注销等。点击主页单元格时,将其推送到主页视图控制器,但选项卡栏消失。
这是菜单视图控制器中侧边栏菜单导航的代码:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! MenuTableViewCell
cell.menuName.text = menuName[indexPath.row]
cell.menuIcon.image = UIImage(named: menuImage[indexPath.row])
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// tableView.deselectRow(at: indexPath, animated: true)
let row = indexPath.row
if row == 0{
let storyboard = UIStoryboard(name: "Home", bundle: nil)
let obj = storyboard.instantiateViewController(withIdentifier: "HomeViewController") as! HomeViewController
let navController = UINavigationController(rootViewController: obj)
navController.setViewControllers([obj], animated:true)
tabBarController?.tabBar.isHidden = false
self.revealViewController().setFront(navController, animated: true)
self.revealViewController().setFrontViewPosition(FrontViewPosition.left, animated: true)
// self.revealViewController().tabBarController?.tabBar.isHidden = false
} else if row == 1{
let storyboard = UIStoryboard(name: "Bookings", bundle: nil)
let obj = storyboard.instantiateViewController(withIdentifier: "BookingsViewController") as! BookingsViewController
let navController = UINavigationController(rootViewController: obj)
navController.setViewControllers([obj], animated:true)
self.revealViewController().setFront(navController, animated: true)
self.revealViewController().setFrontViewPosition(FrontViewPosition.left, animated: true)
} else if row == 2 {
let storyboard = UIStoryboard(name: "Profile", bundle: nil)
let obj = storyboard.instantiateViewController(withIdentifier: "profileViewController") as! profileViewController
let navController = UINavigationController(rootViewController: obj)
navController.setViewControllers([obj], animated:true)
self.revealViewController().setFront(navController, animated: true)
self.revealViewController().setFrontViewPosition(FrontViewPosition.left, animated: true)
} else if row == 3 {
print(indexPath)
// Log out user from Firebase
AuthService.signOut(onSuccess: {
// Present the Sign In VC
// PrefsManager.sharedinstance.logoutprefences()
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let signInVC = storyboard.instantiateViewController(withIdentifier: "signInViewController")
self.present(signInVC, animated: true)
// self.navigationController?.pushViewController(signInVC, animated: true)
}) { (errorMessage) in
ProgressHUD.showError(errorMessage)
}
}
}
在主视图控制器中:
//Hamberg menu - revel view controller
if self.revealViewController() != nil {
menuBtn.target = self.revealViewController()
menuBtn.action = #selector(SWRevealViewController.revealToggle(_:))
self.revealViewController().panGestureRecognizer().isEnabled = true
}
鉴于self.tabBarController?.tabBar.isHidden = false在viewdidload,viewdidappear,viewwillappear中出现,但它不起作用。
任何帮助,不胜感激...