public override void ViewDidLoad() { try { base.ViewDidLoad(); // if (!MediaController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)) { ShowUnsupported(); this.DismissViewControllerAsync(false); return; } FreemediaController(); // set our source to the camera mediaController.SourceType = UIImagePickerControllerSourceType.Camera; // set mediaController.MediaTypes = new string[] { "public.image" }; // show the camera controls // attach the delegate pickerDelegate = new PickerDelegate(this); mediaController.Delegate = pickerDelegate; this.View.AddSubview(mediaController.View); } catch (Exception ex) { Debug.WriteLine("Exception Occured in ViewDidLoad method due to " + ex.Message); } }
private void FreemediaController() { if (Media != null) { ClearMedia(Media.Path); } if (mediaController != null && mediaController.Delegate != null) { if (mediaController.View != null) { mediaController.clearZoomSliderDelegate(mediaController.View.Subviews); } mediaController.Delegate.Dispose(); mediaController.Delegate = null; } if (this.View != null) { foreach (var view in View.Subviews) { view.RemoveFromSuperview(); view.Dispose(); } } if (this.Media != null) { this.Media.Dispose(); } if (pickerDelegate != null) { pickerDelegate.Dispose(); pickerDelegate = null; } //mediaController.Delegate = null; }
/// <summary> /// Dismisses the view controller async. /// </summary> /// <returns>The view controller async.</returns> /// <param name="animated">If set to <c>true</c> animated.</param> public override Task DismissViewControllerAsync(bool animated) { try { if (Media != null) { ClearMedia(Media.Path); } if (mediaController != null && mediaController.Delegate != null) { if (mediaController.View != null) { mediaController.clearZoomSliderDelegate(mediaController.View.Subviews); } mediaController.Delegate.Dispose(); mediaController.Delegate = null; } if (this.View != null) { foreach (var view in View.Subviews) { view.RemoveFromSuperview(); view.Dispose(); } } if (this.Media != null) { this.Media.Dispose(); } if (pickerDelegate != null) { pickerDelegate.Dispose(); pickerDelegate = null; } #if DEBUG var Process2 = Process.GetCurrentProcess(); if (Process2 != null) { Debug.WriteLine(string.Format("memory allocated by DismissViewControllerAsync before memory release = {0}", Process2.WorkingSet64)); } #endif if (mediaController != null) { mediaController.DismissModalViewController(true); mediaController.Dispose(); mediaController = null; } GC.Collect(); this.Dispose(); #if DEBUG var Process1 = Process.GetCurrentProcess(); if (Process1 != null) { Debug.WriteLine(string.Format("memory allocated by DismissViewControllerAsync = {0}", Process1.WorkingSet64)); } #endif return(base.DismissViewControllerAsync(animated)); } catch (Exception ex) { Debug.WriteLine("Exception Occured in DismissViewControllerAsync method due to " + ex.Message); } return(base.DismissViewControllerAsync(animated)); }