ios - Selectively push in viewWillAppear in a UIViewControllerContainer -
we have app model object can pass through various states in progressive fashion - think of order
progressing sale, example. each state of order
handled different view controller.
each view controller recognizes state(s) can handle, , when state has been reached cannot handle, pushes subsequent view controller handle next state. various events can cause vc update view; method setupviewbyorderstate
called @ point. same method called in viewdidappear
.
for example, order
can pass through states 1-10. viewcontroller handles states 1-2, b handles 3-5, , c handles 6-10.
if handed order in state 1 or 2, configures itself. if handed order in state 3 or greater, pushes b, , hands off order. etc.
one advantage of technique first vc 'entry point' - hand given order
, push necessary vcs until 1 reached can handle order
in current state, without logic explicitly coding state->vc correspondences ever needing exist outside each vc.
a problem arises, though, should 1 wish pop backward through view stack or dismiss modals. c popped, viewdidappear
of b called, puts on (to handle order in state) -- puts c on.
what's appropriate pattern dealing this?
checking isbeingpresented
doesn't work. these view controllers in custom uiviewcontrollercontainer
, well. flag read-only, knowledge how gets set great.
just don't use viewdidappear that. when create "next" view controller, create , call view controller specific initialization method handle have been handling in viewdidappear.
you want decouple view appearance order state.
Comments
Post a Comment