我仍然是初学者。我该怎么做,谁的图像和文本已成功上传,以更改为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