locked
How to add selected image from image pickerviewcontoller to list RRS feed

  • Question

  • User306227 posted

    How to add selected image from image pickerviewcontoller to list

    Sunday, June 7, 2020 5:40 AM

All replies

  • User380187 posted

    Hi @Amejack , first create a ListView with ImageView inside the Cell, then add selected image for each cell . You can share somde code you have done in list .

    protected void Handle_FinishedPickingMedia(object sender, UIImagePickerMediaPickedEventArgs e)
    {
        bool isImage = false;
        switch (e.Info[UIImagePickerController.MediaType].ToString())
        {
            case "public.image":
                Console.WriteLine("Image selected");
                isImage = true;
                break;
            case "public.video":
                Console.WriteLine("Video selected");
                break;
        }
    
        // get common info (shared between images and video)
        NSUrl referenceURL = e.Info[new NSString("UIImagePickerControllerReferenceUrl")] as NSUrl;
        if (referenceURL != null)
            Console.WriteLine("Url:" + referenceURL.ToString());
    
        // if it was an image, get the other image info
        if (isImage)
        {
            // get the original image
            UIImage originalImage = e.Info[UIImagePickerController.OriginalImage] as UIImage;
            if (originalImage != null)
            {
                // do something with the image
                imageView.Image = originalImage; // display
            }
    
            UIImage editedImage = e.Info[UIImagePickerController.EditedImage] as UIImage;
            if (editedImage != null)
            {
                // do something with the image
                Console.WriteLine("got the edited image");
                imageView.Image = editedImage;
            }
        } 
    
        // dismiss the picker
        imagePicker.DismissModalViewController(true);
    }
    

    Here is a discussion about selecting an Image from Gallery in Xamarin.ios .

    Monday, June 8, 2020 7:57 AM
  • User306227 posted

    How to select multiple image from image pickerview controller

    Monday, June 8, 2020 10:01 AM
  • User380187 posted

    @Amejack About selecting multiple image , you can have a look at this Forms Sample , and focus on iOS solution how to achieve that .

    Tuesday, June 9, 2020 7:46 AM