【发布时间】:2018-07-02 12:34:19
【问题描述】:
我正在创建一个带有 ActionSheet 样式的 UIAlertController:
UIAlertController actionSheetAlert = UIAlertController.Create(null, null, UIAlertControllerStyle.ActionSheet);
我正在向它添加一个动作:
UIAlertAction alertAction = UIAlertAction.Create("Action", UIAlertActionStyle.Default, DoSomting);
var alertImage = UIImage.FromBundle("image")
.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
alertImage = ResizeImage(sortingAlertImage, 32, 32)
.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
alertAction.SetValueForKey(alertImage, new NSString("image"));
alertAction.SetValueForKey(UIColor.Black, new NSString("titleTextColor"));
actionSheetAlert.AddAction(alertAction);
并显示它:
PresentViewController(_actionSheetAlert, true, null);
如何在点击屏幕时关闭 UIAlertController?
我可以通过添加这样的“取消”操作来做到这一点:
var cancelAlertAction = UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null);
cancelAlertAction.SetValueForKey(UIColor.Black, new NSString("titleTextColor"));
actionSheetAlert.AddAction(cancelAlertAction);
但我不想显示取消操作。
【问题讨论】:
标签: ios xamarin xamarin.ios mvvmcross uialertcontroller