简体   繁体   English

Xamarin.IOS(使用 Rider):每次加载 XCode 或运行模拟器时,创建的图像集都会消失

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

I'm very new to Xamarin.IOS.我对 Xamarin.IOS 很陌生。 I'm using Rider as my IDE.我使用 Rider 作为我的 IDE。 I have a basic project set up, with a tableview.我有一个基本的项目设置,有一个表格视图。 Each cell contains a button and a label.每个单元格包含一个按钮和一个 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.我可以在 C# 中调用该方法,但我一直遇到实际让图像正确加载的问题。

In Xcode, I created two image sets by dragging in two.png files into the Assets.xcassets.在 Xcode 中,我通过将两个.png 文件拖入 Assets.xcassets 中创建了两个图像集。

在此处输入图像描述

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.我已验证单击按钮时是否正确调用了 adjustImage 方法。

I also tried ListItemCheckbox.SetImage(uncheckedImage, UIControlState.Normal);我也试过ListItemCheckbox.SetImage(uncheckedImage, UIControlState.Normal);

Also, when I quit and reopen Xcode, the image sets are completely gone!此外,当我退出并重新打开 Xcode 时,图像集完全消失了!

在此处输入图像描述

Am I missing something obvious?我错过了一些明显的东西吗? I am following the instructions at: https://docs.microsoft.com/en-us/xamarin/ios/app-fundamentals/images-icons/displaying-an-image?tabs=macos我按照以下说明操作: https://docs.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:如果重要的话,我会在控制台中看到一些我不明白的行:

在此处输入图像描述

EDIT:编辑:

I just noticed that when creating the image sets, the rider console spits out these errors:我刚刚注意到,在创建图像集时,骑手控制台会吐出这些错误:

在此处输入图像描述

I have created a new issue for you in JetBrains issue tracker: https://youtrack.jetbrains.com/issue/RIDER-57454我在 JetBrains 问题跟踪器中为您创建了一个新问题: https://youtrack.jetbrains.com/issue/RIDER-57454

UPDATE: Will be fixed in Rider 2021.1更新:将在 Rider 2021.1 中修复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Xamarin iOS-每次我从Visual Studio运行时,用户生成的图像都会消失 - Xamarin iOS - User-generated images disappear every time I run from Visual Studio Rider IDE 无法在 iPhone 设备上运行项目 Xamarin.iOS - Rider IDE can't run project Xamarin.iOS on iPhone device iOS Designer(Xamarin.iOS)使ViewController在创建新Segue时消失 - iOS Designer (Xamarin.iOS) makes ViewController disappear when new Segue is created 每次运行 iOS 模拟器时都是空白的白屏 - Blank white screen every time I run the iOS simulator 地理围栏事件在模拟器上不起作用(Xamarin.ios) - Geofencing events not working on simulator (Xamarin.ios) 如何从 Xamarin.iOS 中的 URL 加载图像 - How to Load an Image from URL in Xamarin.iOS 使用Xamarin.IOS获取相册的最新图像 - Getting Last Image of Album using Xamarin.IOS 在 iOS 模拟器上通过 Xamarin.iOS 使用按需资源的问题 - Issue with using On-Demand Resource through Xamarin.iOS on iOS simulator iOS –每次我在模拟器中运行应用程序时如何运行OCUnit测试 - iOS – How to run OCUnit tests every time I run my application in simulator Xamarin.ios 不适用于真正的 iOS 设备,但它适用于模拟器 - Xamarin.ios does NOT work on real iOS device but it works on Simulator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM