public override void ViewDidLoad() { base.ViewDidLoad(); if (Source != null) { Source.Dispose(); Source = null; } imageCollectionView.DataSource = null; if (cameraView.Image != null) { cameraView.Image.Dispose(); cameraView.Image = null; } cameraView.Layer.CornerRadius = 5f; cameraView.Layer.BorderColor = UIColor.LightGray.CGColor; cameraView.Layer.BorderWidth = 0.5f; cameraView.Layer.ShadowColor = UIColor.LightGray.CGColor; cameraView.Layer.ShadowOpacity = 0.5f; cameraView.Layer.ShadowRadius = 1.0f; cameraView.Layer.ShadowOffset = new System.Drawing.SizeF(1f, 1f); cameraView.Layer.MasksToBounds = false; takePictureButton.TouchUpInside -= HandleTouchUpInside; takePictureButton.TouchUpInside += HandleTouchUpInside; finishButton.TouchUpInside -= FinishButton_TouchUpInside; finishButton.TouchUpInside += FinishButton_TouchUpInside; imageCollectionView.BackgroundColor = UIColor.Clear; try { Debug.WriteLine("UICameraController - line 226"); if (MediaLst != null && MediaLst.Count > 0) { cameraView.Image = MediaLst[MediaLst.Count - 1].Image; cameraImage.Hidden = true; if (imagesList != null) { imagesList.Clear(); } foreach (var img in MediaLst) { imagesList.Add(img.Image); } MediaLst.Clear(); } Source = new CameraDataSource(imagesList, this); imageCollectionView.DataSource = Source; this.cameraImageView = cameraView; } catch (Exception ex) { Debug.WriteLine("Exception Occured in ViewDidLoad method due to " + ex.Message); } }
public override Task DismissViewControllerAsync(bool animated) { ClearCollectionView(); try { this.Media = null; //if (MediaLst != null) { // foreach (var view in MediaLst) { // if (view is UIImageView) { // (view as UIImageView).Image = null; // } // view.RemoveFromSuperview (); // view.Dispose (); // } // MediaLst.Clear (); // MediaLst = null; //} if (image != null) { image.Image = null; image = null; } if (cameraView != null) { cameraView.Image = null; cameraView.Dispose(); } if (currentSelectedImageView != null) { currentSelectedImageView.Image = null; currentSelectedImageView = null; } if (Source != null) { Source.Dispose(); Source = null; } this.Dispose(); GC.Collect(); } catch (Exception ex) { Debug.WriteLine("Exception Occured in DismissViewControllerAsync method due to " + ex.Message); } return(base.DismissViewControllerAsync(animated)); }
private void ClearCollectionView() { try { if (imageCollectionView != null) { if (imageCollectionView.Subviews != null) { foreach (var view in imageCollectionView.Subviews) { if (view is UIImageView) { (view as UIImageView).Image = null; } view.RemoveFromSuperview(); view.Dispose(); } } imageCollectionView.Source = null; imageCollectionView.Delegate = null; imageCollectionView.DataSource = null; imageCollectionView.WeakDelegate = null; imageCollectionView.WeakDataSource = null; imageCollectionView.Dispose(); } if (this.View != null) { if (this.View.Subviews != null) { foreach (var view in this.View.Subviews) { view.RemoveFromSuperview(); view.Dispose(); } } } pictureTaken = null; pictureCollection = null; picture = null; if (image != null) { image.Image = null; image.RemoveFromSuperview(); image.Dispose(); } Source = null; imagesList = null; collectionViewCell = null; if (cameraImageView != null) { cameraImageView.Image = null; cameraImageView.RemoveFromSuperview(); cameraImageView.Dispose(); } if (cameraImage != null) { cameraImage.Image = null; cameraImage.RemoveFromSuperview(); cameraImage.Dispose(); } if (cameraView != null) { cameraView.Image = null; cameraView.RemoveFromSuperview(); cameraView.Dispose(); } GC.Collect(); } catch (Exception ex) { Debug.WriteLine("Exception Occured in ClearCollectionView method due to " + ex.Message); } }