plist 数据到第二个视图
我有一个 plist (字典类型),在一个视图上填充文本视图和标签。我想在第一个视图上有一个信息 UIButton,它链接到一个单独的视图并显示来自同一 plist 的一些数据。
但它必须是来自 plist 中同一记录的数据。
我一切正常,但我坚持将数据传递到第二个视图。
非常感谢任何提示/帮助,
谢谢,
I have a plist (dictionary type) populating text views and labels on one view. I would like to have an info UIButton on this first view that links to a separate view and displays some data from the same plist.
it has to be data from the same record in the plist though.
I have everything working, but I'm stuck at being able to pass that data to the second view.
any hints/help is greatly appreciated,
thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
或者您可以在信息视图中创建一个属性。
@property(nonatomic, keep)NSDictionary *myDic;
当您创建 Info 视图时,将带有数据的字典传递给第二个视图,然后第二个视图将显示数据。 ;-)
Or you could make a property in the info view.
@property(nonatomic, retain)NSDictionary *myDic;
And when you create the Info view, pass your dictionary with the data to the second view, which then displays the data. ;-)
您可以在下一个视图中打开相同的 plist 并以相同的方式读取数据:
您可以为您的字典创建一个
Singleton
访问器类,并让两个视图都请求它的实例来访问相同的数据。或者,如果您以编程方式创建视图,则可以在新视图控制器中创建一个设置器,并从原始视图控制器传递字典的引用。
You could open the same plist in the next view and read the data in the same way:
You could make a
Singleton
accessor class for your dictionary and have both views request an instance of it to gain access to the same data.Or if you create your views programmatically, you could just create a setter in your new view controller and pass a reference of your dictionary from the original view controller.
您可以在第二个视图的 .h 文件中创建一个 NSDictionary,然后当您移动到下一个视图时,设置您想要作为该字典传递的字典。
在第二个视图的.h文件中
You could just Create a NSDictionary in the .h file of the second view and then when you are moving to the next view set the dict you want to pass as that dictionary.
In the .h file of the second view