Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin iOS:如何从文件路径加载WebP_Ios_Xamarin.ios_Webp_Ffimageloading - Fatal编程技术网

Xamarin iOS:如何从文件路径加载WebP

Xamarin iOS:如何从文件路径加载WebP,ios,xamarin.ios,webp,ffimageloading,Ios,Xamarin.ios,Webp,Ffimageloading,我的项目是Xamarin iOS项目。 我尝试使用ffimageloading nuget软件包加载图像,方法如下: var fileURL = NSBundle.MainBundle.PathForResource("test", "webp"); ImageService.Instance.LoadFile(fileURL).Into(imageView); 我甚至使用了其他可用的方法,如embeddedResource、LoadURL、LoadFileFromApplicationBun

我的项目是Xamarin iOS项目。 我尝试使用ffimageloading nuget软件包加载图像,方法如下:

var fileURL = NSBundle.MainBundle.PathForResource("test", "webp");
ImageService.Instance.LoadFile(fileURL).Into(imageView);
我甚至使用了其他可用的方法,如embeddedResource、LoadURL、LoadFileFromApplicationBundle,但都没有用

上述操作均无效,并且imageView为空。同样的代码似乎适用于任何GIF/png文件类型


提前感谢。

经过几个小时的斗争:

可以使用称为WebP.Touch(1.0.8)的ffimageloading依赖库完成此操作:


希望它能帮助别人。

iOS本机支持WebP吗?Safari不支持它。但是他们的GitHub页面说它支持webp-
    WebP.Touch.WebPCodec decoder = new WebP.Touch.WebPCodec();
    var fileURL = NSBundle.MainBundle.PathForResource("imageName", "webp");
    return decoder.Decode(fileURL);