xamarin.forms - 如何使用跨媒体进行多次拍照
问题描述
如何使用 Crossmedia 进行多重拍照,我使用它,它工作得很好,但它会一次又一次地导航,但我不想要这个
bool isCamera = true;
while (isCamera)
{
file = await MediaPicker.TakePhotoAsync(new StoreCameraMediaOptions { SaveToAlbum = true, Name = "", Directory = "" });
if (file != null)
{
//save code}
else{
isCamera=false;
}
解决方案
该插件不支持多选。所以我们需要为每个平台使用依赖服务来实现它。
自己从画廊中挑选媒体。检查本教程。
安卓版
public void OpenGallery()
{
try
{
var imageIntent = new Intent(Intent.ActionPick);
imageIntent.SetType("image/*");
imageIntent.PutExtra(Intent.ExtraAllowMultiple, true);
imageIntent.SetAction(Intent.ActionGetContent);
((Activity)Forms.Context).StartActivityForResult(Intent.CreateChooser(imageIntent, "Select photo"), OPENGALLERYCODE);
Toast.MakeText(Xamarin.Forms.Forms.Context, "Tap and hold to select multiple photos.", ToastLength.Short).Show();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Toast.MakeText(Xamarin.Forms.Forms.Context, "Error. Can not continue, try again.", ToastLength.Long).Show();
}
}
对于 iOS,您可以使用插件https://github.com/roycornelissen/GMImagePicker.Xamarin
推荐阅读
- java - Okhttp: java.net.UnknownHostException
- java - 无法使用 API 29 android studio 在模拟器中运行应用程序
- mysql - 如何使用mysql、rxjs、angular/electron连接mysql服务器
- android - 使用 InputStream 进行 Moshi 解析
- r - 拆分字符串以提取日期和时间
- sql - 如何在 Excel 中使用 SQL 连接获取日期范围提示
- python - 如何在不关闭浏览器的情况下处理旧 URL 后将浏览器重定向到 Robotframework 中的新 URL
- python - 以特定方式重塑熊猫数据框
- vba - 将我的 MS Access 报告数据导出到 Adobe Acrobat DC pdf 时出现问题
- oracle - 提取连续两天或更长时间出现的记录