Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将UIImageView添加到xamarin.forms中的UIAlertView?_C#_Ios_Xamarin_Uiimage_Uialertview - Fatal编程技术网

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

C# 如何将UIImageView添加到xamarin.forms中的UIAlertView?,c#,ios,xamarin,uiimage,uialertview,C#,Ios,Xamarin,Uiimage,Uialertview,这是我正在处理的一段代码。我想在alertbox中显示一个图像作为背景。我已经设置了UIImageView和UIAlertView,但图像没有显示。请帮助我?据我所知,在IOS 7及更高版本上,无法在UIAlertView中添加自定义视图。您必须使用自定义组件来模拟警报,Android有几个选项 我找到了,但没有测试它。吉尔默·托雷斯·卡斯特罗是正确的。版本7和更高版本不支持将UIImageView添加为子视图。 但是,对于版本7及更高版本,您可以使用: UIAlertView alert =

这是我正在处理的一段代码。我想在alertbox中显示一个图像作为背景。我已经设置了
UIImageView
UIAlertView
,但图像没有显示。请帮助我?

据我所知,在IOS 7及更高版本上,无法在UIAlertView中添加自定义视图。您必须使用自定义组件来模拟警报,Android有几个选项


我找到了,但没有测试它。

吉尔默·托雷斯·卡斯特罗是正确的。版本7和更高版本不支持将UIImageView添加为子视图。 但是,对于版本7及更高版本,您可以使用:

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 ();

只有代码的答案对其他读者没有什么价值。强烈建议你提供一些解释,说明你是如何得出结论的。有人标记了你的答案。我编辑了它,因为它仍然试图回答这个问题。您应该添加一些解释,以防止其他人进行解释。
 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();
UIAlertController alert = UIAlertController.Create("Title", "Message Content" , UIAlertControllerStyle.Alert);
UIImageView imageview = new UIImageView();
alert.Add(imageview);