Reputation: 9
I've been having difficulty with getting the images to show in ImageButton in Xamarin.Forms for my iOS application. The buttons are functional, and clickable, but the text and image source is not properly displaying. Instead, there is a clickable blue box, and ellipses as the text value. (https://i.sstatic.net/IrDgx.png) I put the images in the Resources folder with the build action set to BundleResource. I can also display images as a simple image (rather than a button), so I know that iOS can see the images in the folder. I am using the following format to add buttons to my page.
Grid btns = SetUpGrid(1, 0, 0, 0, false);
var ib = new ImageButton();
ib.Image = "account.png";
ib.Text = "Account";
ib.HorizontalOptions = LayoutOptions.Start;
ib.VerticalOptions = LayoutOptions.FillAndExpand;
ib.Clicked += Home_BillClicked;
btns.Children.Add(ib, 0, 1);
Grid.SetColumnSpan(ib, 2);
The images appear and work perfectly in both the WP8 and Android apps. iOS seems to be the only one with an issue rendering the ImageButton. Does anyone know what may be causing the issue?
Upvotes: 0
Views: 2752
Reputation: 11
Instead ib.Image = "account.png", change to ib.Source = "account.png"; and add to your AppDelegate class inherits from XFormsApplicationDelegate.
Upvotes: 1