简体   繁体   中英

How to remove UIViewControllers from hierarchy when segueing to new UIViewControllers?

I'm working on an app that isn't quite "sequential" as far as how the views can go.

For instance, I can get into the following scenario where I segue to new views:

MatchesNavigationController -> ModalOptionsController -> ProfileViewController -> ModalOptionsController -> MatchesNavigationController -> MatchesNavigationController...

And so on and so forth.

In English, what is happening is the user is looking at their matches of people and is inside a text message with a user, then they click a modal options button from the toolbar and it pops up some options, and then the user wants to view their profile. Then from the profile, they can click a button to make the same modal pop up, and from there can then go to the conversation with that person, which will again go back to the navigation controller where they are viewing the conversation. And then from there they can click the options again, go to profile, and repeat...

But then if I'm on the ProfileViewController I can press "back" and that will segue "back" to the MatchesNavigationController via a custom RightToLeft segue that I wrote.

So I can get into instances where the ViewController stack starts to get large and large in this instance.

When I do this as well (go into this cyclical looking workflow), I have a Custom LeftToRight segue that I wrote because I want it to look like, to the user, that they are navigating in that direction.

How do I go about cleaning up the previous views in this cyclical type of navigation that you can get into here?

prepareForSegue: self.navigationController.popViewControllerAnimated(true)之前调用self.navigationController.popViewControllerAnimated(true) ,它将在堆栈中释放当前视图控制器,然后再推送下一个。

经过更多的搜索和挖掘之后,我意识到我想做的比其他事情更加棘手,我花了一个周末来重构视图的布局和呈现方式,并将所有内容都放在UINavigationController内,然后将所有内容推送/弹出应该怎么做,所以我将使这个问题成为可以接受的答案,因为这实际上是我从一开始就应该做的事情。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM