c# - 如何将 UIImageView 添加到 xamarin.forms 中的 UIAlertView?

标签 c# ios xamarin uiimage uialertview

UIAlertView alert = new UIAlertView () { 
    Title = alertTitle, Message = alertMessage
};

UIImageView imageview = new UIImageView ();
UIImage img = UIImage.FromFile ("Resources/Default.png");
imageview.Image = img;
alert.AddSubview (imageview);

alert.AddButton (alertPositiveBtnText);
alert.AddButton (alertNegativeBtnText);
alert.Show ();

这是我正在处理的代码。我想在警报框中显示图像作为背景。我已经设置了UIImageViewUIAlertView 但图像不是出现了。帮帮我?

最佳答案

Guilherme Torres Castro 是正确的。版本 7 及更高版本不支持将 UIImageView 添加为 subview 。 但是,对于版本 7 及更高版本,您可以使用:

 UIAlertView Msg = new UIAlertView()
                    {
                        Title = "Title",
                        Message = "Content" 
                    };
                    UIImageView uiIV = new UIImageView(UIImage.FromFile("ImgFile.Png"));
                    Msg.SetValueForKey(uiIV, (NSString)"accessoryView");
                    Msg.AddButton("OK");
                    Msg.Show();

关于c# - 如何将 UIImageView 添加到 xamarin.forms 中的 UIAlertView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30344452/

相关文章:

c# - 英语自然句的算法

c# - 发送内联 MHTML

iphone - 如何在 Apple 的 Provisioning Portal 中重新注册设备?

c# - 将 Context 绑定(bind)到 ListView 不起作用

c# - 无法在 Android 设备上使用 Xamarin 在 webview 中下载

c# - Xamarin Firebase 发送电子邮件验证

c# - 反序列化包含一组重复元素的字符串

c# - RSA 加密中模数和 p*q 的不匹配值

ios Vision VNImageRequestHandler方向问题

ios - 尝试实现 Facebook 即时文章页面,但我无法获取 ImageView 高度以进行动画处理