簡體   English   中英

在不覆蓋警報的情況下將UIView疊加層添加到KeyWindow

[英]Adding UIView overlay to KeyWindow without covering alerts

我正在嘗試將加載疊加層添加到我的應用程序中,到目前為止,它可以正常運行,只是它出於某種原因覆蓋了警報。

  • 疊加層是全屏UIView,其顯示如下:

     UIApplication.SharedApplication.KeyWindow.AddSubview(view); 
  • 我隨后顯示的警報是這樣創建的:

     var alertController = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert); alertController.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext; viewController.PresentViewController(alertController, true, null); 

問題在於,盡管ModalPresentationStyle設置為OverCurrentContext,但警報仍顯示在疊加層下方。 有沒有一種方法可以強制將它們顯示在所有內容之上?

原因:當您在子keywindow上添加子視圖時,該視圖將出現在屏幕頂部。UIAlertController仍被添加到子keywindow因此它始終位於該視圖的下方。 在此處輸入圖片說明

解決方案:如果您確實想在任何東西的頂部發出警報,則可以使用UIAlertView代替UIAlertController

var alertView = new UIAlertView("title","message",this,"OK",null);
alertView.Show();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM