UIAlertController操作不显示UIView

时间:2019-01-15 09:23:37

标签: ios xamarin.ios uialertcontroller uialertaction

进度对话框只是不想显示,就像它的隐藏内容一样。请查看已采取的步骤和示例代码。

我有以下步骤

  1. 显示的模式(数据列表)
  2. 显示了UIAlertController(密码已过期,需要重新输入密码)
  3. 进度条上的进度条(UIView)
  4. 服务调用运行,直到完成
  5. 关闭进度栏

UIAlertController

private void ShowLogin(string message, Action<ExpiredResponseTypes> responseHandler)
{
     UIApplication.SharedApplication.InvokeOnMainThread(() =>
     {
         var loginAlertController = UIAlertController.Create("Enter password", "", UIAlertControllerStyle.Alert);

         //add login text
         {basic normal code}

         loginAlertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default,
          (actionHandler) =>
          {
              ShowProgress();
              var loginResult = HandleLogin();
              DismissProgress();
              loginResponseHandler(loginResult);
          }));
          AlertAutoLayoutHelper.TopLevelViewController().PresentViewController(loginAlertController, true, null);
   });
}

AlertAutoLayoutHelper.TopLevelViewController

public static UIViewController TopLevelViewController()
    {
        var window = new UIWindow(UIApplication.SharedApplication.KeyWindow.Frame);
        var vc = new UIViewController();
        vc.View.BackgroundColor = UIColor.Clear;
        window.RootViewController = vc;
        window.WindowLevel = UIWindowLevel.Alert + 1;
        window.MakeKeyAndVisible();
        return vc;
    }

ShowProgress

UIApplication.SharedApplication.InvokeOnMainThread(() =>
{
    var bounds = UIScreen.MainScreen.Bounds;
    loadingOverlay = new LoadingOverlay(bounds, optionalMessage, isSpecificLoader);

      if (UIApplication.SharedApplication.KeyWindow.RootViewController.ModalViewController != null)
      {
         UIApplication.SharedApplication.KeyWindow.RootViewController.ModalViewController.View.AddSubview(loadingOverlay);
      }
      else
      { UIApplication.SharedApplication.KeyWindow.RootViewController.View.AddSubview(loadingOverlay);
      }

         isProgressShowing = true;
 });

重叠

 public class LoadingOverlay : UIView
    {
        UIActivityIndicatorView activitySpinner;
        UILabel loadingLabel;

        public LoadingOverlay(CGRect frame, string message = null, bool isSpecificLoader = false) : base(frame)
        {
            {just normal setup }
            AddSubview(activitySpinner);
            AddSubview(loadingLabel);
        }
    }

注意:进度对话框在正常情况下可以正常工作,在从UIViewController调用时显示)

我被困了好几天,请协助。

0 个答案:

没有答案