如何在两个UITableViews之间连接数据?

时间:2021-12-31 23:07:08

I got some trouble and I need some help, here it is: on my project, I built taxi system and each taxi service shown as pin in mapView. each pin has annotation show the name and number of those services. The data is parsed from JSON. On the annotationView, I also have right call out button to view information of every single service. It means that from the annotationView, I put the button and it moves to another view. So how can I do that? the code bellow shows how to get the data from JSON, but in right call out button, how the taxi service info shown in the next view? For example, this annotation view shows ABC taxi service, and in the callout button, it shows the information of that service. The information already parsed from JSON.

我遇到了麻烦,我需要一些帮助,这里是:在我的项目上,我建立了出租车系统和每个出租车服务,在mapView中显示为pin。每个pin都有注释,显示这些服务的名称和数量。数据从JSON解析。在annotationView中,我也有正确的调用按钮来查看每个服务的信息。这意味着,从annotationView中,我把按钮放到另一个视图中。我该怎么做呢?代码bellow显示了如何从JSON获取数据,但是在正确的调用按钮中,如何显示下一个视图中的出租车服务信息?例如,这个注释视图显示了ABC出租车服务,在callout按钮中,它显示了该服务的信息。已经从JSON解析的信息。

for (NSMutableArray *stationDictionary in stationData) {
    station.name = [stationDictionary objectAtIndex:10];
    station.number = [stationDictionary objectAtIndex:11];
    station.info = [stationDictionary objectAtIndex:12];
}

I hope you get my point and I really appreciate your helps. Thanks.

我希望你明白我的意思,我真的很感激你的帮助。谢谢。

1 个解决方案

#1


0  

If you wrap up the information you wish to display in a class, you can pass those objects around (or arrays of multiple objects) from view to view. For instance, in a medical app I've written, when I go from a list of surgical cases to detail about a particular surgical case, I have a list of cases in the first view (which controls what info is displayed there). When the user taps on a particular case to view details, I load the next view (which contains more detail about a particular case) and pass the selected case to the new view.

如果您将希望在类中显示的信息打包,您可以将这些对象(或多个对象数组)从视图传递到视图。例如,在我编写的一个医疗应用程序中,当我从一个外科病例列表到一个特定的外科病例的细节时,我有一个列表,在第一个视图中(它控制了那里显示的信息)。当用户在特定的情况下点击查看详细信息时,我加载下一个视图(其中包含一个特定案例的详细信息),并将选定的案例传递给新视图。

So, you need to lay out a data structure that makes sense of what you have (taxis, services, phone numbers, etc...). Then, parse the JSON into a list of objects. After that, it's a fairly straightforward matter of deciding what info to display on which views at a certain time.

所以,你需要制定一个数据结构,让你知道你拥有什么(出租车、服务、电话号码等等)。然后,将JSON解析为对象列表。在此之后,这是一个相当简单的问题,决定什么信息显示在某个时间的视图上。

#1


0  

If you wrap up the information you wish to display in a class, you can pass those objects around (or arrays of multiple objects) from view to view. For instance, in a medical app I've written, when I go from a list of surgical cases to detail about a particular surgical case, I have a list of cases in the first view (which controls what info is displayed there). When the user taps on a particular case to view details, I load the next view (which contains more detail about a particular case) and pass the selected case to the new view.

如果您将希望在类中显示的信息打包,您可以将这些对象(或多个对象数组)从视图传递到视图。例如,在我编写的一个医疗应用程序中,当我从一个外科病例列表到一个特定的外科病例的细节时,我有一个列表,在第一个视图中(它控制了那里显示的信息)。当用户在特定的情况下点击查看详细信息时,我加载下一个视图(其中包含一个特定案例的详细信息),并将选定的案例传递给新视图。

So, you need to lay out a data structure that makes sense of what you have (taxis, services, phone numbers, etc...). Then, parse the JSON into a list of objects. After that, it's a fairly straightforward matter of deciding what info to display on which views at a certain time.

所以,你需要制定一个数据结构,让你知道你拥有什么(出租车、服务、电话号码等等)。然后,将JSON解析为对象列表。在此之后,这是一个相当简单的问题,决定什么信息显示在某个时间的视图上。