简体   繁体   English

如何在视图之间传递信息

[英]How to pass information between views

I want to pass information like number between two views in navigation controller.我想在导航 controller 中的两个视图之间传递诸如数字之类的信息。 But I don't know how.但我不知道怎么做。

Thanks谢谢

You need to use delegates and protocols.您需要使用委托和协议。 Here is a site with an example http://iosdevelopertips.com/objective-c/the-basics-of-protocols-and-delegates.html这是一个带有示例http://iosdevelopertips.com/objective-c/the-basics-of-protocols-and-delegates.html的站点

Another option might be using singletons if the "numbers" are just a synonym for your application model.如果“数字”只是您的应用程序 model 的同义词,另一种选择可能是使用单例。 Remember, you should use the MVC-concept!请记住,您应该使用 MVC 概念!

http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html

Try the SynthesizeSingleton.h macro if you want a tough solution!如果您想要一个棘手的解决方案,请尝试 SynthesizeSingleton.h 宏!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM