进度对话框只是不想显示,就像它的隐藏内容一样。请查看已采取的步骤和示例代码。
我有以下步骤
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调用时显示)
我被困了好几天,请协助。