xamarin - 如何在 Xamarin.iOS 中使用共享
问题描述
我在这里关注文档:
https://docs.microsoft.com/en-us/xamarin/essentials/share?tabs=android
在我的 Xamarin.iOS 应用中实现共享功能。我的代码:
byte[] pdf = await DownloadPdfFile();
var fn = "myfile.pdf";
var file = Path.Combine(FileSystem.CacheDirectory, fn);
await File.WriteAllBytesAsync(file, pdf);
await Share.RequestAsync(new ShareFileRequest
{
Title = ViewModel.Parameter.Title,
File = new ShareFile(file)
});
运行此代码时没有任何反应。
解决方案
我的猜测是您需要在 info.plist 中添加一些权限
<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app needs access to the photo gallery for saving photos and videos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs access to photos gallery for saving photos and videos.</string>
如果您有任何疑问,请告诉我
推荐阅读
- google-apps-script - 导出工作表数据时如何删除重复的日历事件?
- midi - 使用 javax.sound.midi 接收 midi 输入
- python - 如何在python中从带有实数的数据帧中制作一个包含复数的数据帧?
- google-sheets - 谷歌电子表格:计算特定日期产生的总股息
- kotlin - 使用 kotlin 时条件语法错误
- javascript - 将名称属性应用于文本
- python - 循环 Pandas 列名以创建新数据框
- java - 如何在 JavaFX 中为文本节点的字体大小设置动画
- docker - RSelenium 与 docker 容器和 phantomjs 与 for 循环或 lappy 崩溃
- python - lxml:删除输出中的虚拟命名空间?