从 Popover 中显示的 TableView 中的单元格填充文本字段
在视图控制器中,我有一个按钮,用于创建包含 TableView 的 popOverCOntroller。当用户从该 tableView 中选择某些内容时,我希望 ViewController 中的 TextField 填充 tableView 中的文本,并让 popOverCOntroller 取消显示 ViewController。
popOverCOntroller、ViewController、TableView 代码都可以工作。我不知道如何将文本返回到原始 ViewController。
谢谢,我知道这是抽象的。有人可以告诉我我缺少的步骤吗?
埃里克
In an View Controller, I have a button that creates a popOverCOntroller which contains a TableView. When the user selects something from that tableView, I want a TextField in the ViewController to populate with the text from the tableView and the popOverCOntroller to dismiss showing the ViewController.
The popOverCOntroller, ViewController,TableView code all work. I can't figure out how to get the text back to the original ViewController.
Thanks, and I know this is abstract. Can Someone talk me through the steps I'm missing?
Eric
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以考虑通过 TableViewController 的自定义 init 方法将引用传递给文本字段或可变字符串。
如果您选择传递文本字段,则可以在用户选择行并关闭弹出视图时直接分配值。如果传递可变字符串,则可以设置其值,然后在弹出窗口的委托方法中设置文本字段的值。
如果您需要一些代码来配合它,请告诉我。
编辑
如果您需要以编程方式将其关闭,则需要存储对 UIPopOverController 的弱引用。
labelToUpdate
是我们要更新的标签。在作为父视图控制器的 UIPopOverController 委托中,执行以下操作 –
You can consider passing the reference to the text field or a mutable string via the TableViewController's custom init method.
If you choose to pass the text field, you can directly assign the value when the user selects a row and dismiss the popover view. If you pass a mutable string, you can set its value and later in the popover's delegate method, set the value of the text field.
Let me know if you need some code to go with it.
Edit
You will need to store a weak reference to the UIPopOverController if you need to programmatically dismiss it.
labelToUpdate
is the label we are going to update.In the UIPopOverController delegate, which would be the parent view controller, do this –