I am trying to represent a UIImagePickerController using a Button action. My project crashes with an error:
Got SIGABRT while executing native code. This usually indicates a fatal error in the mono executable version or one of the built-in libraries used by your application.
I only have a ViewController built into the NavigationController in the storyboard. The following are snippets of code:
UIImagePickerController imagePicker; public override void ViewDidLoad() { base.ViewDidLoad(); this.setupImagePicker(); CapturePhotoButton.TouchUpInside += delegate { this.AddMedia(); }; } public void setupImagePicker() { imagePicker = new UIImagePickerController(); imagePicker.SourceType = UIImagePickerControllerSourceType.Camera; imagePicker.ModalPresentationStyle = UIModalPresentationStyle.Popover; imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes( UIImagePickerControllerSourceType.Camera); imagePicker.FinishedPickingMedia += HandleFinishedPickingMedia; imagePicker.Canceled += (sender, e) => { imagePicker.DismissModalViewController(true); }; } public void HandleFinishedPickingMedia(object sender, UIImagePickerMediaPickedEventArgs e) { bool isImage = false; switch (e.Info[UIImagePickerController.MediaType].ToString()) { case "public.image": isImage = true; break; case "public.video": break; } if (isImage) { UIImage originalImage = e.Info[UIImagePickerController.OriginalImage] as UIImage; if (originalImage != null) { PreviewImageView.Image = originalImage; imagePicker.DismissViewController(true, null); } } } public void AddMedia() {
source share