How does [UIAlertView show] work?

寵の児 提交于 2019-12-05 17:45:28

问题


I want to do something similar to UIAlertView, ie - without reference to any UIView or UIViewController, present a UIViewController on top of all windows using presentModalViewController.

Looking at the documentation I can't find a way in which this is possible!

In OS4, there is something like this:

UIWindow *window = [UIApplication sharedApplication].keyWindow
UIViewController *rootViewController = window.rootViewController

...but this is not possible in OS3.

Does anyone know how to achieve the same effect in OS3?

Thanks!


OK - so I solved this with a myriad of delegate callbacks to the ViewController itself! Although it's the proper way to achieve this, it did seem kind-of odd that's it's not possible at any stage in execution get a handle to the top View Controller for alerts (etc).

If anyone knows how to achieve this, I'd be still really interested!


回答1:


UIAlertView creates its own UIWindow above your application's main window, makeKeyAndVisible-s it, and animates in its own views in that window.



来源:https://stackoverflow.com/questions/3725339/how-does-uialertview-show-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!