popViewController 不返回

Sat*_*uki 0 ios parse-platform swift

我正在制作一个从解析中检索图像并将其显示到集合视图的应用程序。当用户点击图像时,图像会显示详细信息。我有一个用户可以更改的文本字段。当用户更改某些内容时,他们会点击保存按钮并返回到集合视图。返回到集合视图控制器的代码不起作用。

  @IBAction func saveButton(sender: AnyObject) {

    // Use the sent country object or create a new country PFObject
    if let saveInBackWithBlock = currentObject as PFObject? {
        updateObject = currentObject! as PFObject
    } else {
        updateObject = PFObject(className:"Tops")
    }

    // Update the object
    if let updateObject = updateObject {

        updateObject["imageText"] = topsLabel.text

        // Create a string of text that is used by search capabilites
        var searchText = (topsLabel.text)
        updateObject["searchText"] = searchText

        // Update the record ACL such that the new record is only visible to the current user
        updateObject.ACL = PFACL(user: PFUser.currentUser()!)

        // Save the data back to the server in a background task
        updateObject.saveInBackgroundWithBlock{
            (success: Bool, error: NSError?) -> Void in
            if (success) {
                // The object has been saved.

            } else {
                // There was a problem, check error.description
            }
        }

        print("saved")

    }
   self.navigationController?.popViewControllerAnimated(true)

        }
Run Code Online (Sandbox Code Playgroud)

我不知道为什么它不返回到之前的视图控制器。谢谢

小智 6

您的父视图是否嵌入在导航控制器中?另外——这个观点是如何表达的?

从您刚刚添加的帖子中 - 您无法弹出模态 VC - 尝试关闭视图控制器。

  • 正如@Mike所说,因为这是一个模态演示,所以您需要执行`self.dismissViewControllerAnimated(false,completion: nil)`(或者如果您想要动画则为true) (4认同)