gpt4 book ai didi

iphone - 如何使用新数据重新加载或刷新选项卡栏 Controller 的选项卡栏中的数据?

转载 作者:行者123 更新时间:2023-12-01 16:57:43 24 4
gpt4 key购买 nike

我有 3 个带有标签栏 Controller 的标签。标签栏中的所有 3 个 View Controller 都有导航 Controller ,可以自行转到其他 View Controller 。

标签栏中的 View Controller 之一是带有 map 和 map 注释( map View Controller )。这些注释来自基于应用程序启动时的当前位置的 Web 服务。在 map View Controller 中,顶部有一个导航栏项(搜索按钮),使您可以在 map 上搜索不同的位置。单击搜索按钮后,搜索 View Controller 将被推送到导航堆栈。搜索完成并找到新位置后,新位置将显示在同一搜索 View Controller 的 TableView 中。

我的目标是在单击表格 View 项后自动返回 map View ,并根据新搜索的位置在 map 上加载新的注释数据。再次显示 map View 后,应用程序首次启动时检索的旧数据应替换为从 Web 获取的新数据。标签栏中的所有 3 个 View Controller 通过单例对象共享注释数据。

我的问题是,当用户单击 中的项目时,我应该怎么做才能使用新数据返回 map View ? didSelectRowAtIndexPath 搜索 View Controller 中的方法?返回选项卡栏中的 map View 并从 Web 服务再次加载数据的最佳方法是什么?

我是否使用' popViewControllerAnimated ' 在搜索 View Controller 中,然后在 map View Controller 中工作 ' 将出现 ' 方法?如何将新位置的纬度和经度值从搜索 View Controller 传递给 map View Controller ?我是否将 map View Controller 导入到搜索 View Controller 中,并将 map View Controller 的 ivar 设置为纬度和经度,即使“搜索 View Controller ”是由“ map View Controller ”插入而产生的?由于 map View Controller 已经在内存中,将 map View Controller 导入搜索 View Controller 有什么复杂性?

我想要完成的事情类似于免费应用程序“Wikihood”在搜索 map 时所做的事情。

非常感谢你。

最佳答案

看来您可以使用单例对象作为数据模型。这样,viewWillAppear:只显示数据模型中当前设置的任何位置,并且您的搜索 Controller 有一个方便的位置来放置其结果。

想到的其他选项是委托(delegate)或通知,但由于您已经拥有模型对象,因此继续使用它是一致的。

关于iphone - 如何使用新数据重新加载或刷新选项卡栏 Controller 的选项卡栏中的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10049644/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com