做了款跑步的app,其中部分页面的逻辑如上图。
我再开始跑步页面和跑步中的页面跳转中用的push
方式,跑步中页面到跑步暂停模式,再到成果分享这个页面全部都使用的model
方式,调用的presentModalViewController
方法。
请求,如果我想从分享成果直接返回到开始跑步界面,可不可以连续调用两次dismissViewControllerAnimated
和一次nav的pop
从而实现?
如果有其他方式可以完成这个逻辑,求告知!
【ps:(暂停→跑步)这个箭头忘记画了】
There is no need to call
dismissViewControllerAnimated
twice, directly letrunning VC
call itsNavigationController
'sPOP
toWhen VC
pops up during running, three VCs can be released at once.dismissViewControllerAnimated
,直接让跑步中VC
调用其NavigationController
的POP
将跑步中VC
弹出就可以一次性释放三个VC了。原理你懂吧,跑步暂停和分享跑步成果是present出来的,相当于是
跑步中VC
的枝(子VC),所以父VC弹出,就都弹出了。如果你不知道如何在
跑步成果分享
这个垮了两层的VC去反向调用跑步中VC
的方法,我这里有几个方案:使用通知中心
NSNotificationCenter
如果不是万不得已,不建议过多使用,容易让代码变得晦涩难懂协议回调delegate,传统方法,稍微麻烦一点
在
分享跑步成果
VC中,[[self presentingViewController] presentingViewController]
就是你的跑步中VC
,相信你已经懂了。祝你好运。
PS
小伙子, 我以为我数错了。
其实我上面说的是对的,只是
跑步中VC
也是没有navigationController
的。他的父节点才有
所以 还要再调一次
You know the principle, running pause and sharing running results are presented, which is equivalent to the branches (child VCs) ofpresentingViewController
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-
Use the notification center
Running VC
inRunning Results Sharing
, which has collapsed two layers, I have a few solutions here:NSNotificationCenter
If it is not a last resort, it is not recommended to use it too much, as it can easily make the code obscureShare running results
VC,[[self presentingViewController] presentingViewController]
is yourrunning VC
, I believe you already understand . 🎜Boy, I thought I counted wrong. 🎜 🎜Actually, what I said above is correct, but
running VC
does not havenavigationController
. 🎜 🎜Only his parent node has it🎜 🎜So I have to adjustpresentingViewController
again 🎜🎜🎜🎜🎜presentModalViewController method
has been deprecated since iOS7! Are you referring to thepresentViewController:animated:completion
method?presentModalViewController方法
自iOS7就弃用了!你是指presentViewController:animated:completion
这个方法吧!在
VCs under theNavigationController
层级下的VC可以通过popToViewController
这个方法跳转到指定VC,而通过present形式打开的Modal样式的VC,只能通过dismissModalViewController
NavigationController
level can jump to the specified VC through thepopToViewController
method, while Modal style VCs opened in the present form can only be accessed throughdismissModalViewController
to disappear. 🎜