【问题标题】:how to go back to a tableviewcontroller after an action has been submitted?提交操作后如何返回 tableviewcontroller?
【发布时间】:2021-01-02 05:04:44
【问题描述】:

我在我的应用程序中创建了提交审核操作。当用户提交时,他会收到成功警报。

在成功警报之后,我希望应用程序将用户重定向回应用程序中的上一页。我的帖子评论页面也是“当前模式”类型的,那么我如何在用户提交后使其下拉?

这是我的任务

这是我在提交时查看给用户的消息

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)})}

如何将他重定向回我的 tableviewcontroller?

【问题讨论】:

标签: ios swift


【解决方案1】:

把这个放在你的dismiss函数中,不需要Timer,只需要DispatchQueue,然后dismiss完成:

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)
            }
        }
    }

【讨论】:

  • @mike 祝你有美好的一天:)
【解决方案2】:
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)
})}

【讨论】:

  • 您好,谢谢您的回答,我在询问之前尝试过此操作,因为我拥有的页面类型以模态方式存在,所以它不起作用。所以它不会关闭页面并将其下拉。
猜你喜欢
  • 1970-01-01
  • 2017-03-14
  • 2023-01-07
  • 1970-01-01
  • 2021-04-20
  • 1970-01-01
  • 2018-10-18
  • 1970-01-01
  • 2012-05-09
相关资源
最近更新 更多