【发布时间】:2026-02-14 01:50:01
【问题描述】:
我将 Xam.Plugin.Media 用于我的项目。它在 android 版本中完美运行,但在 iOS 中......它使用 buttonClick 打开图库,但我无法选择照片,它们就像不可选择。你有什么想法吗?
这是我的代码:
await CrossMedia.Current.Initialize();
if (!CrossMedia.Current.IsPickPhotoSupported)
{
return;
}
try
{
file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions { PhotoSize = PhotoSize.Medium });
if (file == null)
{
return;
}
alert = UIAlertController.Create("Info", file.Path.ToString(), UIAlertControllerStyle.Alert);
alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
PresentViewController(alert, true, null);
}
catch (Exception ex)
{
alert = UIAlertController.Create("Info", ex.ToString(), UIAlertControllerStyle.Alert);
alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
PresentViewController(alert, true, null);
}
编辑:我在真实设备上测试过,效果很好。但我不知道为什么它在模拟器上不起作用。
【问题讨论】:
-
权限好吗?并且这个包已经合并到Essentia
-
是的,我实现了对 info.plist 的权限。我会在尝试 Essentials MediaPicker 后提供反馈 :)
-
你是在ios模拟器还是真机上测试。
-
在 iOS 模拟器 iPhone 11 (14.5) 上测试。有什么方法可以在真机上测试吗?
-
将 iphone 连接到 mac 并将模拟器切换到您的设备 ID?
标签: c# xamarin xamarin.forms xamarin.ios