简体   繁体   English

如何从带有XIB文件的另一个UIView中获取值?

[英]How do I get a value from another UIView with XIB file?

I have two XIB files.The first one with my app view and then the user can fill with required informations. 我有两个XIB文件,第一个是我的应用程序视图,然后用户可以填写所需的信息。 The second is a form and the user can start typing some name and my table view will be like a autofill field. 第二个是表单,用户可以开始输入一些名称,而我的表格视图将像自动填充字段。

The question is, how can I open the second view allowing the user to do his research and after that send the user back to another screen with the selected information? 问题是,如何打开允许用户进行研究的第二个视图,然后将用户返回到具有所选信息的另一个屏幕?

You can manage this data in many ways.. 您可以通过多种方式管理此数据。

1) You can use ur singleton data class, to handle to & from data. 1)您可以使用ur singleton数据类来处理数据。

2) You can use appDelegate handle the data. 2)您可以使用appDelegate处理数据。

3) You can have data object say NSDictionary so that open exit from second view, data is sent to first view. 3)您可以将数据对象说成NSDictionary以便从第二个视图打开出口,将数据发送到第一个视图。

In my opinion use the third option, have a method in first view like.. 我认为使用第三个选项,在第一个视图中有一个方法。

-(void)setData(NSDictionary*)data
{
enter code here
}

set the data, and set the pointer of first view to second view, while alloc and presenting the second view. 设置数据,并将第一个视图的指针设置为第二个视图,同时alloc并显示第二个视图。

On exiting the second view, using that pointer send the data using that method.. 退出第二个视图时,使用该指针使用该方法发送数据。

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

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