On the click of button
In Xamarin.IOS Project implement Interface
private async void btnOpenGallery(object sender, EventArgs e) { DependencyService.Get<IMediaService>().GetGMImageStreamAsync(); }Create Interface to open Image Picker
public interface IMediaService { void GetGMImageStreamAsync(); }
In Xamarin.IOS Project implement Interface
public class MediaService: UIViewController, IMediaService { public void GetGMImageStreamAsync() { GMImagePickerController picker=new GMImagePickerController(); picker.MediaTypes = new[] { PHAssetMediaType.Image }; picker.Title = "Add Images"; picker.CustomDoneButtonTitle = "Add"; picker.CustomCancelButtonTitle = "Cancel"; picker.AllowsMultipleSelection = true; picker.FinishedPickingAssets += (sender, e) => { PHImageManager imageManager = new PHImageManager(); PHImageRequestOptions options = new PHImageRequestOptions(); options.DeliveryMode = PHImageRequestOptionsDeliveryMode.HighQualityFormat; options.ResizeMode = PHImageRequestOptionsResizeMode.Exact; options.Synchronous = true; options.NetworkAccessAllowed = true; imageManager.RequestImageForAsset(asset, new CGSize(asset.PixelWidth, asset.PixelHeight), PHImageContentMode.Default, null, (image, info) => { // var data = image.AsJPEG(); // byte[] imageData = data.ToArray(); }); }; /optional picker.Canceled += Picker_Canceled; UIWindow window = UIApplication.SharedApplication.KeyWindow; var viewController = window.RootViewController; viewController.PresentModalViewController(picker, true); } }