我需要创建一个弹出菜单,当按下集合视图单元格时,我可以在其中更改集合视图中的数据。

I need to create like a pop up menu where I can change data in a collection view when the collection view cell is pressed.

基本上,问题已经说明了一切。我想到了一个警报,但我实际上需要在里面有一个文本框,并且能够将文本保存到标签中。关于我应该在其中使用什么的任何想法?我不想在导航中创建一个新的视图控制器。我只是想根据需要打开和关闭弹出视图。

非常感谢所有建议。谢谢!

您可以在 alertController 中添加文本字段。

请参考这个回答

let alertController = UIAlertController(title: "Your alert", message: "", preferredStyle: .alert)

let saveAction = UIAlertAction(title: "Save", style: .default, handler: {
    alert -> Void in

    guard let textField = alertController.textFields?[0] as UITextField else { return }
    yourLabel.text = textField.text
})

let cancelAction = UIAlertAction(title: "Cancel", style: .default, handler: {
    (action : UIAlertAction!) -> Void in })

alertController.addTextField { (textField : UITextField!) -> Void in
    textField.placeholder = "Whatever"
    //Other textField configurations
}

alertController.addAction(saveAction)
alertController.addAction(cancelAction)

present(alertController, animated: true, completion: nil)