ios - 成功后切换回启动窗口

标签 ios swift xcode

我还是初学者。 我该怎么办,谁的图片和文字已经成功上传到TableView了?

 @IBAction func postImage(_ sender: Any) {

    if let image = imageTopost.image {


        let post = PFObject(className: "Post")

        post["message"] = comment.text

        post["userId"] = PFUser.current()?.objectId

        if let imageData = UIImagePNGRepresentation(image){


            let activityIndicator = UIActivityIndicatorView(frame: CGRect(x:0, y: 0, width: 50, height: 50))
            activityIndicator.center = self.view.center
            activityIndicator.hidesWhenStopped = true
            activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.gray
            view.addSubview(activityIndicator)
            activityIndicator.startAnimating()
            UIApplication.shared.beginIgnoringInteractionEvents()


            let imageFile = PFFile(name: "image.png", data: imageData)
            post["imageFile"] = imageFile
            post.saveInBackground(block: { (success, error) in


                activityIndicator.stopAnimating()
                UIApplication.shared.endIgnoringInteractionEvents()


                if success {
                    self.displayAlert(title: "Hat super geklappt", message: "Dein Ziel wurde erfolgreich hinzugefügt")
                    self.comment.text = ""
                    self.imageTopost.image = nil

                }else {

                    self.displayAlert(title: "Etwas ist schiefgelaufen" , message: "Dein Bild konnte leider nicht gespeichert werden. Versuche es nochmal. Dein Internet muss eingeschalten sein." )
                }
            })
        }
    }
}

我想我这里就是代码。但不幸的是我不知道如何做到这一点

              if success {
                    self.displayAlert(title: "Hat super geklappt", message: "Dein Ziel wurde erfolgreich hinzugefügt")
                    self.comment.text = ""
                    self.imageTopost.image = nil

                }else {

                    self.displayAlert(title: "Etwas ist schiefgelaufen" , message: "Dein Bild konnte leider nicht gespeichert werden. Versuche es nochmal. Dein Internet muss eingeschalten sein." )
                }
            })
        }

最佳答案

您可以尝试更改根 VC

let homeView = self.storyboard?.instantiateViewController(withIdentifier: "homeView")
let nav = UINavigationController(rootViewController: homeView!)
nav.navigationBar.isHidden = true
UIApplication.shared.keyWindow?.rootViewController = nav

关于ios - 成功后切换回启动窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49475851/

相关文章:

ios - CollectionView 无法正常工作

ios - 有没有办法从 ios 项目自动创建 UML 图?

iOS - 自定义 View 未填充 super View

swift - 快速切换时在两个变量之间来回切换的最佳方法

ios - Xcode 无法识别已经定义的 Sprite ?

ios - UITableView 未填充

ios - 如何将变量分离到其他文件并访问

ios - ipad:将一个 UITableViewCell 从一个 UITableViewController 拖放到另一个 UITableViewController 中

ios - 此应用程序的 XCode 项目类型? OpenGL ES 还是基于 View ?

ios - UICollectionViewCells 在 reloadData() 后不显示