存储文本并在下一个视图中检索
我在第一个视图中有一个 UITextField,我必须存储文本并检索到下一个视图。谁能帮我解决这个问题?
I have a UITextField in the first view, I have to store the text and retrieve onto the next view. Who can help me with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该调查代表。它允许一个视图向另一个视图提供回调,而无需创建紧密耦合。
http://www.theappcodeblog.com/2011/04/15/passing-data- Between-views-tutorial-using-a-protocol-delegate-in-your-iphone-app/
<一个href="https://stackoverflow.com/questions/7215698/what-exactly-does-delegate-do-in-xcode-project/7215969#7215969">delegate 在 xcode ios 项目中到底做了什么?
另一种选择是创建共享模型(阅读模型视图控制器模式)。在该模式中,通常通过获取模型的单例实例来创建模型并共享数据:
You should look into delegates. It allows one view to provide a callback to another view without creating tight coupling.
http://www.theappcodeblog.com/2011/04/15/passing-data-between-views-tutorial-using-a-protocol-delegate-in-your-iphone-app/
What exactly does delegate do in xcode ios project?
Another option is to create a shared model (read up on model view controller patterns). It's typical in that pattern to create a model and share data by getting a singleton instance of your model:
您可以使用 NSUserDefaults 来存储数据,并且可以在任何类中检索
要存储:
要检索:
You can use NSUserDefaults to store the data and you can retrieve in any class
To Store:
To retrieve: