【问题标题】:Camera and Gallery For Cross-Platform (Xamarin)跨平台的相机和图库 (Xamarin)
【发布时间】:2018-03-01 05:23:02
【问题描述】:

我需要在 Android/Ios 的 xamarin 中使用相机/图库。有什么办法吗?

【问题讨论】:

    标签: xamarin xamarin.forms xamarin.android


    【解决方案1】:

    首先,在您的解决方案中安装插件:“Xam.Plugin.Media”

    为相机编写此代码并获取文件:

    var file = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions() { SaveMetaData = true, PhotoSize = PhotoSize.MaxWidthHeight });
    

    为 Gallery 编写此代码并获取文件:

    var file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions() { SaveMetaData = true, PhotoSize = PhotoSize.MaxWidthHeight });
    

    这项工作适用于 Xamarin 中的 Android 和 Ios 平台。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-07
      • 1970-01-01
      • 1970-01-01
      • 2018-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多