0

i created a submit review action in my application. when a user submits he gets a success alert.

after the success alert i want the application to redirect the user back to the previous page in the application. also my post review page is of type"present modally", so how will i be able to make it drop down after user submitted?

here is my let

this is the message that i view to the user upon submission

let messageVC = UIAlertController(title: "Review submitted successfully!", message: "" , preferredStyle: .actionSheet)
                self.present(messageVC, animated: true) {
                    Timer.scheduledTimer(withTimeInterval: 2.0, repeats: false, block: { (_) in
                        messageVC.dismiss(animated: true, completion: nil)})}

how can i redirect him back to my tableviewcontroller?

  • https://stackoverflow.com/questions/28760541/programmatically-go-back-to-previous-viewcontroller-in-swift – Roman Ryzhiy Sep 15 '20 at 12:36
  • @RomanRyzhiy will this work for tableview aswell? –  Sep 15 '20 at 12:43
  • @RomanRyzhiy my submit review page is of type present modally, so will this work aswell in this case? –  Sep 15 '20 at 12:46

2 Answers2

1

Put this in you dismiss function, no Timer needed just DispatchQueue after and dismiss completion:

let messageVC = UIAlertController(title: "Review submitted successfully!", message: "" , preferredStyle: .actionSheet)
    present(messageVC, animated: true) {
        DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
            messageVC.dismiss(animated: true) {
                self.dismiss(animated: true, completion: nil)
            }
        }
    }
Fabio
  • 5,432
  • 4
  • 22
  • 24
0
let messageVC = UIAlertController(title: "Review submitted successfully!", message: "" , preferredStyle: .actionSheet)
                self.present(messageVC, animated: true) {
                    Timer.scheduledTimer(withTimeInterval: 2.0, repeats: false, block: { (_) in
                        messageVC.dismiss(animated: true, completion: nil)
                        self.dismiss(animated: true, completion: nil)
})}
Esraa Ragab
  • 296
  • 2
  • 9
  • hi thank you for your answer, i tried this before asking, it doesn't work since the type of page i have is present modally. so it will not dissmiss the page and drop it down. –  Sep 15 '20 at 12:53