嗨,我在使用 Xamarin 进行 iOS 开发的 MvvmCross 图片选择器插件时遇到了一个奇怪的问题。我正在开发一种表单,用户可以在其中选择/拍摄多张照片和一段视频。
我的应用程序允许用户从相机胶卷或直接从表单中添加多张照片。
对于捕获视频,我使用Xamarin.Mobile api。
我正在使用选择的 MvvmCross 图片来执行此操作。使用相机拍摄 1 或 2 张图像/视频时会出现此问题。
当第三次重新进入相机屏幕时捕获 1 或 2 张图像/视频时,图像是静态的并且不会更新相机取景器。视图停留在最后捕获的任何内容的最后一帧。
我在这里描述了同样的问题,但唯一的区别是我使用了 MvvmCross 图片选择插件。
在我的代码中,我曾经将命令与我的按钮绑定如下:
// MyView is inherited from MvxViewController (of mvvmcross)
var set = this.CreateBinding<MyView,MyViewModel>();
//Binding button to picture chooser command
set.Bind(this.TakePhotoButton).To(vm=>vm.TakePictureCommand);
在我的视图模型中:
public MvxCommand TakePictureCommand
{
get
{
this.takePictureCommand => this.takePictureCommand ?? new MvxCommand(()=>
this.pictureChooserTask.TakePicture(300,95,this.OnPictureSelected,
()=>{}),,this.CanTakeOrChoosePicture);
}
}
private void OnPictureSelected(Stream stream)
{
using(var memoryStream = new MemoryStream())
{
stream.CopyTo(memoryStream);
// PictureBytes is a property which i am using to bind with image view
this.PictureBytes= memoryStream.ToArray();
}
}
private bool CanTakeOrChoosePicture()
{
return this.PictureBytes= null;
}
谁能指导我我做错了什么?