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 ();
This is the piece of code i am working upon.I want to show an image as background in alertbox.I have set the UIImageView
and UIAlertView
but image is not showing up.Help me?
Guilherme Torres Castro is correct. versions 7 and later do not support adding UIImageView as subView. However, for version 7 and above you can use this:
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();
As far i Know on IOS 7 and up it´s impossible to add custom view in UIAlertView. You have to use a custom component to mimic the Alert, there a few options for Android.
I found this library for Xamarin , but didn't test it.
UIAlertController alert = UIAlertController.Create("Title", "Message Content" , UIAlertControllerStyle.Alert);
UIImageView imageview = new UIImageView();
alert.Add(imageview);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.