[UIAlertView 显示] 是如何工作的? [英] How does [UIAlertView show] work?

查看:46
本文介绍了[UIAlertView 显示] 是如何工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做一些类似于 UIAlertView 的事情,即 - 不参考任何 UIView 或 UIViewController,使用 presentModalViewController 在所有窗口之上呈现一个 UIViewController.

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!

在 OS4 中,有这样的东西:

In OS4, there is something like this:

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

...但这在 OS3 中是不可能的.

...but this is not possible in OS3.

有谁知道如何在OS3中实现同样的效果?

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

谢谢!

好的 - 所以我通过无数对 ViewController 本身的委托回调解决了这个问题!虽然这是实现这一目标的正确方法,但似乎有点奇怪,因为在执行的任何阶段都不可能获得顶部视图控制器的句柄以获取警报(等).

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!

推荐答案

UIAlertView 在应用程序的主窗口上方创建自己的 UIWindowmakeKeyAndVisible-s 它,并在该窗口中自己的视图中设置动画.

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

这篇关于[UIAlertView 显示] 是如何工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆