Ejemplo n.º 1
0
            public override async void FinishedPickingMedia(UIImagePickerController picker, NSDictionary info)
            {
                await picker.PresentingViewController?.DismissViewControllerAsync(true);

                var mediaType = (NSString)info[UIImagePickerController.MediaType];

                if (mediaType == UTType.Image)
                {
                    var image = (UIImage)(info[UIImagePickerController.EditedImage] ?? info[UIImagePickerController.OriginalImage]);
                    image.SaveToPhotosAlbum((img, error) => {
                        if (error != null)
                        {
                            var alert = UIAlertController.Create("picker.camera.image-not-saved.title".Translate(defaultValue: "Image Not Saved"),
                                                                 "picker.camera.image-not-saved.message".Translate(defaultValue: "Sorry, unable to save the new image!"),
                                                                 UIAlertControllerStyle.Alert);

                            alert.AddAction(UIAlertAction.Create("picker.action.ok".Translate(defaultValue: "OK"), UIAlertActionStyle.Default, null));
                            _parent.PresentViewController(alert, true, null);
                        }

                        // Note: The image view will auto refresh as the photo's are being observed in the other VCs
                    });
                }
                else if (mediaType == UTType.Movie)
                {
                    NSUrl           videoPathUrl = (NSUrl)info.ObjectForKey(UIImagePickerController.MediaURL);
                    ALAssetsLibrary lib          = new ALAssetsLibrary();
                    lib.WriteVideoToSavedPhotosAlbum(videoPathUrl, (url, error) => {
                        if (error != null)
                        {
                            var alert = UIAlertController.Create("picker.camera.video-not-saved.title".Translate(defaultValue: "Video Not Saved"),
                                                                 "picker.camera.video-not-saved.message".Translate(defaultValue: "Sorry, unable to save the new video!"),
                                                                 UIAlertControllerStyle.Alert);

                            alert.AddAction(UIAlertAction.Create("picker.action.ok".Translate(defaultValue: "OK"), UIAlertActionStyle.Default, null));
                            _parent.PresentViewController(alert, true, null);
                        }

                        // Note: The image view will auto refresh as the photo's are being observed in the other VCs
                    });
                }
            }
            public override async void FinishedPickingMedia(UIImagePickerController picker, NSDictionary info)
            {
                await picker.PresentingViewController.DismissViewControllerAsync(true);

                var mediaType = (NSString)info[UIImagePickerController.MediaType];

                if (mediaType == UTType.Image)
                {
                    var image = (UIImage)(info[UIImagePickerController.EditedImage] ?? info[UIImagePickerController.OriginalImage]);
                    image.SaveToPhotosAlbum((img, error) => {
                        if (error != null)
                        {
                            var alert = UIAlertController.Create("Image Not Saved",
                                                                 "Sorry, unable to save the new image!",
                                                                 UIAlertControllerStyle.Alert);

                            alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                            _parent.PresentViewController(alert, true, null);
                        }

                        // Note: The image view will auto refresh as the photo's are being observed in the other VCs
                    });
                }
            }