ios - How to present view controller properly? -


i have pretty simple application couple of uiviewcontrollers (say vc_a , vc_b). every screen has button allows switch screen (no uinavigation used).

app schedules local notification, which, when expired, should present view controller (vc_n - no matter screen active @ moment).

the problem application throws:

'nsinternalinconsistencyexception', reason: 'attempting begin modal transition   <vc_a: 0x2021e0> <vc_n: 0xf84b970> while transition in progress.   wait viewdidappear/viewdiddisappear know current transition has completed' 

what proper way implement such behaviour?

a. use uiviewcontroller's new presentviewcontroller:animated:completion present 3 controllers instead of old modal method.

b. create boolean flag , initialize no.

c. before view controller presentation, check flag. if yes, set no. , present vc. in completion block, set flag yes again.

d. app should ignore flag when present initial view controller whether vc_a or vc_b.

one pitfall if button got pressed or local notification expired while view controller in transition state, new vc won't presented. 1 can improve upon logic present after if needed.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -