跳转到导航堆栈中的某个点

发布于 2024-10-25 11:30:47 字数 599 浏览 0 评论 0原文

只是在得到了一些建议并朝着正确的方向推动之后。

我有一个带有导航控制器的模态视图,其中包含 3 个级别(视图):

  1. 我的活动作业(从服务器中提取用户活动作业的列表并显示为表格,选择一个作业,然后视图 2 传递 jobID并显示)。

  2. 作业详细信息(根据来自服务器的 jobID 提取作业详细信息及其更新列表,选择更新并查看 3 传递 updateID 并显示)。

  3. 更新详细信息(根据服务器上的 updateID 以及该更新附加的任何照片提取更新的详细信息,选择一张照片,它会全屏显示。

因此我在应用程序的不同部分有一个单独的模式视图,其中显示了作业的最新更新,其中包括新作业。分配给用户和活动作业的新更新,

当在最新更新模式窗口中选择一个项目时,我想做的是直接链接到导航控制器中的相关视图,

所以我的想法是调用活动作业。选择最新更新并传递相关 ID 时的模态视图,初始化堆栈中所需的视图组合,将 ID 传递给视图,然后使用 setViewControllers:animated: 方法初始化导航控制器

。最好的方法,或者有更好的方法吗?

任何帮助或建议将不胜感激。

Just after a bit of advice really and a push in the right direction.

I have a modal view with a navigation controller containing 3 levels (views):

  1. My Active Jobs (pulls a list of the users active jobs from the server and displays as a table, select a job and view 2 is passed the jobID and displayed).

  2. Job Details (pulls the job details and a list of its updates based on the jobID from the server, select an update and view 3 is passed the updateID and displayed).

  3. Update Details (pulls the details of the update based on the updateID from the server and any photos attached to that update, select a photo and it displays full screen.

So I have a seperate modal view in a different part of the app which displays the latest updates to the jobs. This includes new jobs assigned to the user and new updates for active jobs.

What I would like to do is link directly to the relevant view in the navigation controller when an item is selected in the latest updates modal window.

So my thoughts are to call the the Active jobs modal view when a latest update is selected and pass the relevant ID(s), initialise the combination of views needed in the stack pass the ID(s) to the views then initialise the navigation controller with the setViewControllers:animated: method.

Is this the best way to do it, or is there a better way?

Any help or suggestions would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愁杀 2024-11-01 11:30:47

我认为没有理由重复为视图控制器创建视图的功能。您可以做的一件事是为每个元素( jobId 和 updateId )都有一个“缓存”。如果你想一次推送多个 viewController,你可以用所需的值填充缓存。然后,当您将视图控制器推送到导航控制器上时,新控制器将检查缓存,如果缓存了某些内容,您只需直接推送下一个视图控制器即可。这一切都会很快发生,并且用户不会注意到。

通过这种方式,无论您是否知道下一个 id,您都将使用相同的代码。您要么使用用户选择的 ID,要么使用其他选择已经预定义的 ID。

I don't see a reason to duplicate the functionality of creating the views for the view controller. One thing you could do is have a "cache" for each element (jobId and updateId ). If you want to push multiple viewControllers at once you would fill the cache with the desired values. Then when you push a viewController onto the navigationController, the new controller would check the cache and if there is something cached you would simply push the next view controller directly. This would all happen quickly and should be unnoticeable to the user.

By doing it this way, you are using the same code regardless of if you know the next id or not. You are either using the user selected id, or the one already predefined by the other selection.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文