0

I'm very new to Xamarin.IOS. I'm using Rider as my IDE. I have a basic project set up, with a tableview. Each cell contains a button and a label. I can register the button press. What I want to do is change the icon of the button when I click on it. I can get the method to be called in C#, but I keep running into issues actually getting an image to load properly.

In Xcode, I created two image sets by dragging in two .png files into the Assets.xcassets.

enter image description here

I am loading my images like so:

    UIImage checkedImage;
    UIImage uncheckedImage;


    public CampingListCell(IntPtr handle) : base(handle) {
        checkedImage = UIImage.FromBundle ("checked");
        uncheckedImage = UIImage.FromBundle("unchecked");
    }

Then I swap images with

    void AdjustImage() {
        switch (listItem.CurrentCheckedState) {
            case CheckedState.Checked:

                ListItemCheckbox.ImageView.Image = checkedImage;
                break;
            case CheckedState.NotChecked:
                ListItemCheckbox.ImageView.Image = uncheckedImage;
                break;
            default:
                throw new ArgumentOutOfRangeException();
        }
    }

However, when I run the program int he simulator, there's just a blank button. I have verified that the adjustImage method is being called properly on the click of the button.

I also tried ListItemCheckbox.SetImage(uncheckedImage, UIControlState.Normal);

Also, when I quit and reopen Xcode, the image sets are completely gone!

enter image description here

Am I missing something obvious? I am following the instructions at: https://learn.microsoft.com/en-us/xamarin/ios/app-fundamentals/images-icons/displaying-an-image?tabs=macos

If it matters I'm getting some lines in the console that I don't understand:

enter image description here

EDIT:

I just noticed that when creating the image sets, the rider console spits out these errors:

enter image description here

Adam B
  • 3,662
  • 2
  • 24
  • 33

1 Answers1

1

I have created a new issue for you in JetBrains issue tracker: https://youtrack.jetbrains.com/issue/RIDER-57454

UPDATE: Will be fixed in Rider 2021.1

xtmq
  • 3,380
  • 22
  • 26
  • Thank you. So is this a rider problem? And not an Xcode problem? Is rider wiping the asset folder somehow? – Adam B Feb 02 '21 at 18:41
  • I am not sure, but probably yes – xtmq Feb 02 '21 at 21:56
  • I just loaded up the project in visual studio and the images load fine. So confirmed it's a rider issue. This basically prevents me from using rider. Hopefully it gets fixed soon! – Adam B Feb 04 '21 at 03:48
  • Also, now, after loading them in visual studio, they work when running from rider debug simulator. – Adam B Feb 04 '21 at 03:50
  • 1
    I think Rider is failing to copy the images over from the Xcode project. That’s why you can use VS to get it working. – Hackmodford Feb 08 '21 at 12:51
  • I've run into similar issues with new outlets from Xcode (right click dragging) not being included by rider. Quitting and restarting both Xcode and rider seemed to solve this issue. Didn't have any issues doing same operations in VS – Adam B Feb 11 '21 at 23:26