Search

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Tuesday, September 30, 2014

How to load UIImage from web URL ?


How to load UIImage from web URL ?

UIImage img=Images.Fromuri("www.google.com/my.jpg");

Common Class :

public static Class Images
{
Public static UIImage FromUrl (string uri)
{
    using (var url = new NSUrl (uri))
    using (var data = NSData.FromUrl (url))
        return UIImage.LoadFromData (data);
}
}

How to choose a photo From Phone album?

In Xamarin.iOS Application for choose a photo from album .we need to use UIImagePickerController

Follow below step for show photo album Controller

1.  Create the image picker control
Var Imagepicker=new UIImagePickerController();

2.    Set the Source and media Type

Imagepicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
Imagepicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.PhotoLibrary);

3.Create Delegate event for image chose & cancel image selection.
Imagepicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
Imagepicker.Canceled += Handle_Canceled;

4.Show Image controller

 NavigationController.PresentModalViewController(Imagepicker, true);

5.  Implement Image choose event

protected void Handle_FinishedPickingMedia (object sender, UIImagePickerMediaPickedEventArgs e)
{
    // determine what was selected, video or image
    bool isImage = false;
    switch(e.Info[UIImagePickerController.MediaType].ToString()) {
        case "public.image":
        // get the original image
        UIImage originalImage = e.Info[UIImagePickerController.OriginalImage] as UIImage;
        if(originalImage != null) {
            // do something with the image
            Console.WriteLine ("got the original image");
            imageView.Image = originalImage; // display
            break;
        case "public.video":
            Console.WriteLine("Video selected");
            break;
    }

    // dismiss the picker
    imagePicker.DismissModalViewControllerAnimated (true);
}

     6 .Cancel Image controller

void Handle_Canceled (object sender, EventArgs e) {
       Imagepicker.DismissModalViewControllerAnimated(true);

}

3. Which controller we can use for Phone photo album access?

UIImagePickerController

2 comments:

  1. Devenvexe.Com/Xamarin: How To Load Uiimage From Web Url ? >>>>> Download Now

    >>>>> Download Full

    Devenvexe.Com/Xamarin: How To Load Uiimage From Web Url ? >>>>> Download LINK

    >>>>> Download Now

    Devenvexe.Com/Xamarin: How To Load Uiimage From Web Url ? >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete
  2. English is not my first language, and I needed help with my essays to improve my language skills. I found an online essay writing service https://www.outlookindia.com/outlook-spotlight/7-best-services-that-can-write-my-research-paper-news-264216 that offers language editing and proofreading services. Their skilled editors provided feedback on my writing and helped me enhance the clarity and coherence of my essays.

    ReplyDelete