简体   繁体   English

使用Xamarin.IOS获取相册的最新图像

[英]Getting Last Image of Album using Xamarin.IOS

I'm trying to get the last image from the album and share it on social media but whenever I tried searching for solutions, they are all either in Objective-C or Swift and I don't really understand either of the language. 我正试图从专辑中获取最后一张图片并在社交媒体上分享,但每当我尝试搜索解决方案时,他们都是在Objective-C或Swift中,而且我对这两种语言都不太了解。

I searched for solutions and got this which is in Objective-C: Get last image from Photos.app? 我搜索了解决方案并得到了Objective-C中的这个: 从Photos.app获取最后一张图片?

and I have problems trying to convert the code myself from Objective-C to C# in Xamarin.IOS 我在Xamarin.IOS中尝试将代码自己从Objective-C转换为C#时遇到问题

The main problem that I got stuck with when converting is this line 转换时遇到的主要问题是这一行

fetchOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]];

I could not find sortDescriptorWithKey anywhere in Xamarin.IOS 我在Xamarin.IOS的任何地方都找不到sortDescriptorWithKey

It is in the constructor according to the documentation: https://developer.xamarin.com/api/type/Foundation.NSSortDescriptor/#Public_Constructors 根据文档在构造函数中: https//developer.xamarin.com/api/type/Foundation.NSSortDescriptor/#Public_Constructors

so something like: 像这样的东西:

fetchOptions.SortDescriptors = new NSSortDescriptor[] {new NSSortDescriptor("creationDate", false)};

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM