在我的应用中,使用了锁屏。有时会显示一个
UIAlertView
,现在当用户将应用程序推到后台并再次前置时,UIAlertview
会显示在锁屏上方。是否有可能添加一个UIViewController
的视图在所有内容之上,即在UIAlertView
之上?UIAlertView
,现在当用户将应用程序推到后台并再次前置时,UIAlertview
会显示在锁屏上方。是否有可能添加一个UIViewController
的视图在所有内容之上,即在UIAlertView
之上?UIWindow *mySpecialWindowForLockScreen = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
//"Hey iOS Please put this window above all alert view"
mySpecialWindowForLockScreen.windowLevel = UIWindowLevelAlert+100;
UIViewController *lockScreenViewController = [[UIViewController alloc]init];//Lock Screen
lockScreenViewController.view.frame = mySpecialWindowForLockScreen.bounds;
mySpecialWindowForLockScreen.rootViewController = lockScreenViewController;
// In lockScreenViewController view you can add lock screen images and other UI stuff
mySpecialWindowForLockScreen.rootViewController.view.backgroundColor = [UIColor greenColor];
[mySpecialWindowForLockScreen makeKeyAndVisible];
mySpecialWindowForLockScreen
,因此我必须为其创建一个属性。 - swalknerUIWindowLevel有三种类型,级别越高的窗口将显示在其他窗口之上。
因此,我建议您使用一个UIWindow来创建锁屏页面,并将其窗口级别设置为大于UIWindowLevelAlert
。
基本上,它们的值如下:
UIWindowLevelNormal = 0.000000;
UIWindowLevel UIWindowLevelAlert = 2000.000000;
UIWindowLevel UIWindowLevelStatusBar = 1000.000000;
所以这就是为什么警告视图会显示在其他窗口之上。你可以试一试。
UIAlertView
的引用,并将其隐藏起来。当应用再次进入前台时,由你决定如何处理alertView的引用。 - Vinod VishwanathUIAlertView
应该在所有东西的顶部 - 这是它的职责 - 提醒。 - Unheilig