infinitered / rmq

RMQ - RubyMotionQuery
MIT License
307 stars 52 forks source link

Include childModalViewControllers when checking rmq.app.current_view_controller #314

Open HealsCodes opened 8 years ago

HealsCodes commented 8 years ago

I know the topic of detecting the current view controller is a hairy one (I had my fair share of it). But would it be possible to extend rmq.app.current_view_controller and in that respect rmq.view_controller to check and respect if a view has an active childModalViewController?

As it is right it's not possible to use presentViewController with any of both methods if a there is currently a modal view controller on screen.

I know it sounds strange but one real world use case would be displaying a UIAlertController from a modal view. I came across this while debugging a missing alert box from RedAlert. Turns out rmq.view_controller is the culprit as it doesn't traverse down my modal VC resulting in an error like this:

Warning: Attempt to present <UIAlertController: 0x11e10c7f0> on <StartScreen: 0x12325fe50> whose view is not in the window hierarchy!

StartScreen in this case is the VC below my current modal screen. There's currently an open issue on this for RedAlert but IMHO the real fix belongs in RMQ.