ios - Is there any way to create and use an unwind segue programmatically? -


i have series of 3 view controllers, first 2 of wrapped in uinavigationcontroller, , managed default main.storyboard file. let's call them a , b, respectively. have more view controllers throughout file, each instantiated , managed separately, though working on moving them all-code solutions. aforementioned third view controller have in code (c) 1 @ various times instantiated , presented b.

a , b have normal segue relationship setup in interface builder , called via code. same c b, via code (instantiate , presentviewcontroller(_:)). there few cases action in c invalidates b's raison d'ĂȘtre, , must dismiss both.

so far, have been calling dismissviewcontrolleranimated(_:) c, , checking in b's viewdidappear(_:) whether should dismissed, , dismissing same way if so. during process, user thrown though vc hierarchy, watching empty views fly whence came, leaving time them experiment controls no longer work, , may crash app. rather disconcerting user experience wish away with. disable everything, that's lot of controls i'd rather not mess if can avoid it...

i understand ib supports "unwind segues," can dismiss entire vc hierarchy simultaneously, though seem handle view controllers in storyboard. there way behavior (dismiss a) programmatically, without having revert of work i've done, considering part of hierarchy contained in uinavigationcontroller?


update:

so, got dismissal work properly, passing reference presenting view, , calling dismiss segue before leaving. approach came own issues , navigation controller weirdness, tweaking might usable.

honestly, easier remove feature entirely @ point, it's convenience.

for sake of science, i'm going keep @ until decide ether way, , answer here googling way.


update:

ew... seems code older thought. have 2 navigation controllers, support custom modal animation , out of b, custom unwind segue there (there go). in order animation want, may toss c storyboard , make custom unwind segue.

if don't care animation, disabling animation on custom unwind got both b , c vanish promptly, , together. trouble is, it's bit jolting taste...

vacawama's suggestion makes lot of sense, , serves me right not checking documentation! uiviewcontroller keeps reference presentingviewcontroller. going 2 pinch, climbing hierarchy , dismissing 1 want. works charm, without animation doesn't happen @ all...

gonna post answer here i've found far.

so, science prevails, , solution found.

it's pain if don't writing custom segues , animators. gonna eventually, it's more profitable not enable feature @ all. (thank goodness it's easy toggle on end).

i found running dismiss segue (i use custom one) on b, dismissing c did trick, long didn't use animations either. nothing unexpected there @ all!

further, same effect in 1 line (animation doesn't matter, neither custom segue) running:

presentingviewcontroller?.presentingviewcontroller?.dismissviewcontrolleranimated(true, completion: nil) 

from c's equivalent of goallthewayback().

gross, got job done. bit more tweaking, using storyboard (ugh) unwind segue , writing custom animator, it'd fancier pig in blanket!

i'd declare horse , dead. all!


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -