Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add AlertView in didselect sidemenu cell clicked? #132

Open
KaranVakharia789 opened this issue Oct 28, 2021 · 1 comment
Open

How to add AlertView in didselect sidemenu cell clicked? #132

KaranVakharia789 opened this issue Oct 28, 2021 · 1 comment

Comments

@KaranVakharia789
Copy link

I want to add alertView with done and cancel button but i clicked cell Logout menu at that time my current Viewcontroller popToViewController Login Screen and after show Alert but i need on done button popToViewController my code

override func viewDidLoad() {
    super.viewDidLoad()
        sideMenuController?.cache(viewControllerGenerator: {
            self.storyboard?.instantiateViewController(withIdentifier: "LoginVC")
        }, with: "1")
    sideMenuController?.delegate = self
}

and below code in didSelectRow

    let refreshAlert = UIAlertController(title: GlobalConstants.APPNAME, message: "Are you sure you want to logout?", preferredStyle: UIAlertController.Style.alert)
    refreshAlert.addAction(UIAlertAction(title: "Yes", style: .default, handler: { (action: UIAlertAction!) in
        print("Handle Ok logic here")
       
        if #available(iOS 13.0, *) {
            let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
            let vc = storyBoard.instantiateViewController(withIdentifier: "LoginVC") as! LoginVC
            self.navigationController?.popToViewController(vc, animated: true)
        } else {
            // Fallback on earlier versions
            let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
            let vc = storyBoard.instantiateViewController(withIdentifier: "LoginVC") as! LoginVC
            self.navigationController?.popToViewController(vc, animated: true)
        }
        
    }))
    
    refreshAlert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (action: UIAlertAction!) in
        print("Handle Cancel Logic here")
    }))
    
    present(refreshAlert, animated: true, completion: nil)
@KaranVakharia789
Copy link
Author

how to implement alertview in sidemenu clicked and after ok clicked popToViewController on login page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant