objective-c - 关于iOS页面间的跳转。
PHPz
PHPz 2017-04-17 17:24:51
0
2
251

做了款跑步的app,其中部分页面的逻辑如上图。
我再开始跑步页面和跑步中的页面跳转中用的push方式,跑步中页面到跑步暂停模式,再到成果分享这个页面全部都使用的model方式,调用的presentModalViewController方法。
请求,如果我想从分享成果直接返回到开始跑步界面,可不可以连续调用两次dismissViewControllerAnimated和一次nav的pop从而实现?
如果有其他方式可以完成这个逻辑,求告知!

【ps:(暂停→跑步)这个箭头忘记画了】

PHPz
PHPz

学习是最好的投资!

reply all(2)
Ty80

There is no need to call dismissViewControllerAnimated twice, directly let running VC call its NavigationController's POP to When VC pops up during running, three VCs can be released at once. dismissViewControllerAnimated ,直接让跑步中VC调用其NavigationControllerPOP跑步中VC弹出就可以一次性释放三个VC了。

原理你懂吧,跑步暂停和分享跑步成果是present出来的,相当于是跑步中VC的枝(子VC),所以父VC弹出,就都弹出了。

如果你不知道如何在跑步成果分享这个垮了两层的VC去反向调用跑步中VC的方法,我这里有几个方案:

  1. 使用通知中心 NSNotificationCenter 如果不是万不得已,不建议过多使用,容易让代码变得晦涩难懂

  2. 协议回调delegate,传统方法,稍微麻烦一点

  3. 分享跑步成果VC中,[[self presentingViewController] presentingViewController]就是你的跑步中VC,相信你已经懂了。

祝你好运。

PS
小伙子, 我以为我数错了。

其实我上面说的是对的,只是跑步中VC也是没有navigationController的。

他的父节点才有

所以 还要再调一次 presentingViewController

You know the principle, running pause and sharing running results are presented, which is equivalent to the branches (child VCs) of running VC, so when the parent VC pops up, they all pop up.

If you don’t know how to reversely call the method of Running VC in Running Results Sharing, which has collapsed two layers, I have a few solutions here:

Use the notification center NSNotificationCenter If it is not a last resort, it is not recommended to use it too much, as it can easily make the code obscure

  • 🎜Protocol callback delegate, traditional method, a little more troublesome🎜
  • 🎜In Share running results VC, [[self presentingViewController] presentingViewController] is your running VC, I believe you already understand . 🎜
  • 🎜Good luck to you. 🎜 🎜PS
    Boy, I thought I counted wrong. 🎜 🎜Actually, what I said above is correct, but running VC does not have navigationController. 🎜 🎜Only his parent node has it🎜 🎜So I have to adjust presentingViewController again 🎜🎜🎜🎜🎜
    左手右手慢动作

    presentModalViewController method has been deprecated since iOS7! Are you referring to the presentViewController:animated:completion method? presentModalViewController方法自iOS7就弃用了!你是指presentViewController:animated:completion这个方法吧!

    NavigationController层级下的VC可以通过popToViewController这个方法跳转到指定VC,而通过present形式打开的Modal样式的VC,只能通过dismissModalViewController

    VCs under the NavigationController level can jump to the specified VC through the popToViewController method, while Modal style VCs opened in the present form can only be accessed through dismissModalViewController to disappear. 🎜
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!