当一个视图调用第二个视图并且第二个视图关闭时,程序返回到哪里?
我一整天都在研究在视图之间传递变量值的经典问题。 (我已经阅读并输入了我在书中和网上找到的几乎所有示例!) 我的第二个视图是一个选择器,我必须检索行值并将其发送回调用程序。我已经设法将数据从第一个视图传递到选择器的视图,但是当第二个视图控制器关闭时,第一个视图控制器中运行什么方法?也就是说,我应该在哪里放置代码来接收选择器的值?
顺便说一句,我选择了传递值的共享实例方法,可以在 http://www.cocoanetics.com/2009/05/the-death-of-global-variables/
谢谢, -抢
I've been working all day on that classic problem of passing variable values between views. (I've read and typed in almost every example I've found in my books and on the net!)
My second view is a picker, and I have to retrieve the row value and send it back to the calling program. I've managed to pass data from the first view to the picker's view, but what method runs in the first view controller when the 2nd view controller closes? That is, where do I put the code to receive the picker's value?
Incidentally, I settled on the Shared Instances method of passing the values, found at http://www.cocoanetics.com/2009/05/the-death-of-global-variables/
Thanks,
-Rob
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 Sams Teach Yourself iPad in 24 Hours 中找到了问题的答案。该代码进入 viewWillAppear 方法。它类似于 ViewDidLoad,但它用于从不同的 View 返回 View。例如,如果您要更新第一个视图上的标签,并使用第二个视图设置的数据,则传递的数据将设置到 viewWillAppear 中的标签中。
I found an answer to my question in Sams Teach Yourself iPad in 24 Hours. The code goes into the viewWillAppear method. It's like ViewDidLoad but it's for returning to the View from a different View. If you are updating a label, for example, on the first view with data set by the second view, the data being passed is set into the label in viewWillAppear.