Forum Xamarin.Forms

How to take multiple pictures using camera in xamarin IOS?

i am using xamarin forms. In android i used intent for taking multiple pictures. But in IOS i know how to take single image in one click. I want to know how to implement multiple image capture using camera in IOS.

Tagged:

Best Answers

  • rakeshraghavanrakeshraghavan INMember ✭✭
    Accepted Answer

    @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

  • seanydaseanyda GBMember ✭✭✭✭✭

    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.

    var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
        {
            Directory = "Sample",
            Name = "test.jpg"
        });
    
        if (file == null)
            return;
    
        await DisplayAlert("File Location", file.Path, "OK");
    
        image.Source = ImageSource.FromStream(() =>
        {
            var stream = file.GetStream();
            file.Dispose();
            return stream;
        }); 
    
    RUNMETHODAGAIN();
    
  • rakeshraghavanrakeshraghavan INMember ✭✭

    @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

  • seanydaseanyda GBMember ✭✭✭✭✭

    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.

  • rakeshraghavanrakeshraghavan INMember ✭✭

    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
    }

  • rakeshraghavanrakeshraghavan INMember ✭✭

    Is there any solution for my issue?

  • Gigex42Gigex42 USMember ✭✭✭✭

    @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
    }

    Then create a user input letting the user decide how many pictures he wants to take?

  • rakeshraghavanrakeshraghavan INMember ✭✭
    Accepted Answer

    @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;
    }

    }

  • TahsinTahsin DEMember

    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 -.-

  • TahsinTahsin DEMember

    We finished our beta test you can get a trial version on our web page, just google for xamarin forms photo plugin (cross-apps)

Sign In or Register to comment.