我正在创建一个ios应用程序,但问题是我不知道如何在登录成功后不添加登录菜单而无需实现登录屏幕的情况下实现并成功工作,但是在登录屏幕后如何使用却无法使用,因为这是我正在创建的第一个应用程序让我展示了Sidemenu的代码
我正在使用KYDrawerController作为辅助菜单
在App Delegate中,我已经完成了
$user = get_user_by( 'login', $username );
if($user && wp_check_password($pass, $user->data->user_pass, $user->ID)){
echo "That's it";
}
else{
echo "Nope";
}
在ViewController的“按钮操作”中,我正在像这样从appdelegate使用它
var drawer = KYDrawerController.init(drawerDirection: .left, drawerWidth: 260)
let storyBoard = UIStoryboard.init(name: "Main", bundle: Bundle.main)
let mainVC = storyBoard.instantiateViewController(withIdentifier: "Screen2")
let menuVC = storyBoard.instantiateViewController(withIdentifier: "Drawer")
self.drawer.mainViewController = mainVC
self.drawer.drawerViewController = menuVC
self.window?.rootViewController = self.drawer
self.window?.makeKeyAndVisible()
现在,请告诉我在点击登录按钮并成功登录后如何使用
在这里我直接设置了mainVC,但是在登录时却无法设置,因为我想在登录后显示sidemenu
我希望你能理解我的问题,请帮忙如何做
供参考,我已使用此示例完成
答案 0 :(得分:0)
func setUpHomeVC() {
var vc: UIViewController?
let storyBoard = UIStoryboard.init(name: "Main", bundle: Bundle.main)
if let user = AppHelper.getCurrentUser() { // if user is login in
//this is slider menu VC
let drawerViewController = storyBoard.instantiateViewController(withIdentifier: "Drawer")
//this is homeVC
let mainViewController = storyBoard.instantiateViewController(withIdentifier: "Screen2")
let drawerController = KYDrawerController(drawerDirection: .left, drawerWidth: 0.8 * (UIScreen.main.bounds.width))
let navController = UINavigationController(
rootViewController: mainViewController)
navController.view.backgroundColor = UIColor.white
drawerController.mainViewController = navController
drawerController.drawerViewController = drawerViewController
self.window?.rootViewController = drawerController
}else{
vc = SignUpVC() // this is user login VC
let mainVcIntial = UINavigationController(rootViewController: vc!)
mainVcIntial.isNavigationBarHidden = true
self.window?.rootViewController = mainVcIntial
}
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
self.window?.backgroundColor = UIColor.white
setUpHomeVC()
return true
}
希望这会对您有所帮助。