Xamarin.Forms iOS UIKit.UIImage Error

喜夏-厌秋 提交于 2020-01-06 02:18:07

问题


I've been working with making a mobile app using Xamarin.Forms. I have everything working on android, but when I try to launch on iOS I get the error:

System.Exception: Could not initialize an instance of the type 'UIKit.UIImage': the native 'initWithContentsOfFile:' method returned nil.
>It is possible to ignore this condition by setting MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure to false.
....

Does anyone know how to solve this?

Edit: Here is the code it gives me the error on, but I have the feeling something else is causing it:

using System;
using System.Collections.Generic;
using System.Linq;

using Foundation;
using UIKit;

namespace CloudClubv1._2_.iOS
{
    public class Application
    {
        // This is the main entry point of the application.
        static void Main(string[] args)
        {
            // if you want to use a different Application Delegate class from "AppDelegate"
            // you can specify it here.
            UIApplication.Main(args, null, "AppDelegate");
        }
    }
}

回答1:


So it turns out the error was being caused by trying to give an icon to a tabbed view. This works fine on android, but apparently on ios it isn't supported, so to fix the error I just had to comment out the line where the an icon for the tabbed view was set.




回答2:


Make sure on IOS project, set Resources/image properties to BundledResources. In my project they were set to AndroidResources, when I corrected to BundledResources my start working fine.



来源:https://stackoverflow.com/questions/33619308/xamarin-forms-ios-uikit-uiimage-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!