public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); if (_isFromCamera && IsMovingToParentViewController) { RotatePhotoIfNeeded(); _cropView.AdjustImageViewSize(ImageAssets[0].Item2); _cropView.imageView.Image = ImageAssets[0].Item2; _cropView.ApplyCriticalScale(); _cropView.ZoomTap(true, false); _cropView.SetScrollViewInsets(); } }
private void PickImage(UIImage img, NSDictionary info) { var previousZoomScale = _cropView.ZoomScale; var previousOffset = _cropView.ContentOffset; var previousOriginalSize = _cropView.originalImageSize; var previousOrientation = _cropView.orientation; var currentPhoto = source.ImageAssets.FirstOrDefault(a => a.Asset.LocalIdentifier == pickedPhoto.Item2.LocalIdentifier); if (currentPhoto?.Orientation != null && currentPhoto?.Orientation != UIImageOrientation.Up) { currentPhoto.Image = img = ImageHelper.RotateImage(img, currentPhoto.Orientation); _cropView.orientation = currentPhoto.Orientation; } else { _cropView.orientation = UIImageOrientation.Up; } _cropView.AdjustImageViewSize(img); _cropView.imageView.Image = img; if (source.MultiPickMode) { if (previousPhotoLocalIdentifier != pickedPhoto.Item2.LocalIdentifier || currentPhoto == null) { var lastPhoto = source.ImageAssets.FirstOrDefault(a => a.Asset.LocalIdentifier == previousPhotoLocalIdentifier); if (lastPhoto != null) { lastPhoto.Offset = previousOffset; lastPhoto.Scale = previousZoomScale; lastPhoto.OriginalImageSize = previousOriginalSize; lastPhoto.Orientation = previousOrientation; } if (currentPhoto == null) { _cropView.ApplyRightScale(); _cropView.SetScrollViewInsets(); source.ImageAssets.Add(new SavedPhoto(pickedPhoto.Item2, img, _cropView.ContentOffset)); } else { _cropView.ApplyRightScale((float)currentPhoto.Scale); _cropView.SetScrollViewInsets(); _cropView.SetContentOffset(currentPhoto.Offset, false); } } else { if (source.ImageAssets.Count != 1) { source.ImageAssets.RemoveAll(a => a.Asset.LocalIdentifier == pickedPhoto.Item2.LocalIdentifier); } _cropView.ApplyRightScale(); _cropView.SetScrollViewInsets(); } photoCollection.ReloadData(); } else { _cropView.ApplyCriticalScale(); if (source.ImageAssets.Count == 0) { source.ImageAssets.Add(new SavedPhoto(pickedPhoto.Item2, img, _cropView.ContentOffset)); } else { source.ImageAssets[0] = new SavedPhoto(pickedPhoto.Item2, img, _cropView.ContentOffset); } if (_toSquareMode) { _cropView.ZoomTap(_toSquareMode, false); } _cropView.SetScrollViewInsets(); } NavigationItem.RightBarButtonItem.Enabled = true; }