UIAlertView上面的UIView

在我的应用程序中,使用locking屏幕。 有时会显示UIAlertView ,现在当用户将应用程序发送到后台并将其重新放在前面时, UIAlertview会显示在locking屏幕上方。 是否有可能添加一个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]; 

每当你想隐藏LockScreen窗口,然后通过setHidden:YES隐藏它。

有三种UIWindowLevel,最大的一个会显示在另一个窗口的上方。

所以我build议你使用一个UIWindow来创build你的锁屏,让它的窗口级别比UIWindowLevelAlert

基本上,他们的价值是:

  UIWindowLevelNormal = 0.000000; UIWindowLevel UIWindowLevelAlert = 2000.000000; UIWindowLevel UIWindowLevelStatusBar = 1000.000000; 

所以这就是为什么警报视图会显示在另一个窗口的上方。试试看。