I'm developing an app to log book that children have read. So I would like to know how to make the page transition back to the menu page after clicking the "save" button. I also want to make the alert that shows "Data has been saved!". Below are my codes.
@IBOutlet weak var newBookSaveButton: UIButton!
    @IBAction func newBookTapped(_ sender: Any) {
        guard let uid = Auth.auth().currentUser?.uid,
                      let data = bookData() else {
                          return
                      }
                db.collection("new reading").document(uid).setData(data)
            }
            
        
            func bookData() -> [String: Any]? {
                guard let title = bookTitleTextField.text,
                      let author = bookAuthorTextField.text,
                      let summary = bookSummaryTextField.text else {
                          return nil
                      }
                let data: [String: Any] = [
                    "bookTitle": title,
                    "bookAuthor": author,
                    "bookSummary": summary
                ]
                return data
        
                self.transitionToMenu()
            }
    func transitionToMenu() {
       
        let MenuViewController = storyboard?.instantiateViewController(withIdentifier: Constants.Storyboard.MenuViewController) as? MenuViewController
        
        view.window?.rootViewController=MenuViewController
        view.window?.makeKeyAndVisible()
    }
}
With this code, I still unable to transition back to the Menu page. Your help are very much appreciated.
 
     
    