@rakeshraghavan said:
As you told i repeated the code in loop .But suppose if user only want 2 images?
for (int i = 0; i < 3; i++)
{file = await MediaPicker.TakePhotoAsync(new StoreCameraMediaOptions { SaveToAlbum = true, Name = "", Directory = "" }); if (file != null){
//code to save
}
The user can press cancel at anytime to stop taking pictures, and it'll hit the return
and stop running the code. But its ran the logic to save the images each time a photo has been taken.
@seanyda Thanks a lot.
I added a infinite loop .i user press back button in android and user click cancel in ios the loop will exit
bool isCamera = true;
while (isCamera)
{
file = await MediaPicker.TakePhotoAsync(new StoreCameraMediaOptions { SaveToAlbum = true, Name = "", Directory = "" });
if (file != null)
{
//save code}
else{
isCamera=false;
}
}
Answers
I might be wrong but I believe there are limitations on the iOS API preventing you taking multiple photos. The workaround I have is use the Xam.Plugin.Media plugin and once the image has been taken, fire the same call.
It keeps looping through until the user presses cancel.
@seanyda thank you for your reply. These code is for taking a single photo. But i need to open my camera and take multiple pictures at a time. In android i used MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA. But in IOS I dont have any idea
Yeah but what the code is doing is opening up the camera, Taking a photo, closing the camera and then instantly reopening it again. So you're taking multiple photos because it's rerunning the method without any more user input. It's not exactly what you're looking for but it's a workaround.
As you told i repeated the code in loop .But suppose if user only want 2 images?
for (int i = 0; i < 3; i++)
{
{
//code to save
}
Is there any solution for my issue?
Then create a user input letting the user decide how many pictures he wants to take?
The user can press cancel at anytime to stop taking pictures, and it'll hit the
return
and stop running the code. But its ran the logic to save the images each time a photo has been taken.@seanyda Thanks a lot.
I added a infinite loop .i user press back button in android and user click cancel in ios the loop will exit
bool isCamera = true;
while (isCamera)
{
file = await MediaPicker.TakePhotoAsync(new StoreCameraMediaOptions { SaveToAlbum = true, Name = "", Directory = "" });
if (file != null)
{
//save code}
else{
isCamera=false;
}
}
We had the same request several times in our app projects, therefore we started developing a plugin for that. You can try CrossApps.Photo.Plugin it allows you to take multiple images in one view, but is still beta -.-
We finished our beta test you can get a trial version on our web page, just google for xamarin forms photo plugin (cross-apps)