Search code examples
iosxcodexamarinxamarin.iosrider

Xamarin.IOS (using Rider): created image sets disappear every time I load XCode or run simulator


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


Solution

  • 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