Open M1ndaugasJ opened 9 years ago
Hi, @iamsoheavy
Did you implement following methods?
- (UIImageView *)transitionSourceImageView;
- (UIColor *)transitionSourceBackgroundColor;
- (CGRect)transitionDestinationImageViewFrame;
If you show the example code to fail check protocol, I will support in detail.
Hello, here's an example from my project, it works well in Swift 2 (except "supporting UIViewControllerInteractiveTransitioning" and "incorrect layout after dismissing view controller after rotating the screen").
You need to use as? protocol<RMPZoomTransitionAnimating, RMPZoomTransitionDelegate>
to replace the ObjC codes id <RMPZoomTransitionAnimating, RMPZoomTransitionDelegate>
.
You need to inherit both RMPZoomTransitionAnimating and RMPZoomTransitionDelegate to make sure animator.sourceTransition
and animator.destinationTransition
are not nil
.
// MARK: - UINavigationControllerDelegate
extension NewsViewController: UINavigationControllerDelegate {
func navigationController(navigationController: UINavigationController, animationControllerForOperation operation: UINavigationControllerOperation, fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
if fromVC is RMPZoomTransitionAnimating && toVC is RMPZoomTransitionAnimating {
let animator = RMPZoomTransitionAnimator()
animator.goingForward = (operation == .Push)
animator.sourceTransition = fromVC as? protocol<RMPZoomTransitionAnimating, RMPZoomTransitionDelegate>
animator.destinationTransition = toVC as? protocol<RMPZoomTransitionAnimating, RMPZoomTransitionDelegate>
return animator
} else {
return nil
}
}
}
// MARK: - RMPZoomTransitionAnimating/RMPZoomTransitionDelegate
extension NewsViewController: RMPZoomTransitionAnimating, RMPZoomTransitionDelegate {
func imageViewFrame() -> CGRect {
if let collectionView = self.collectionView(),
let indexPath = self.selectedIndexPath,
let cell = collectionView.cellForItemAtIndexPath(indexPath) as? NewsCollectionViewCell,
let imageView = cell.fgImageView {
let frame = imageView.convertRect(imageView.frame, toView: self.view.window)
return frame
}
return CGRectZero
}
func transitionSourceImageView() -> UIImageView! {
let imageView = UIImageView()
imageView.clipsToBounds = true
imageView.userInteractionEnabled = false
imageView.contentMode = .ScaleAspectFill
imageView.frame = imageViewFrame()
imageView.image = self.selectedNewsViewCell?.fgImageView!.image
return imageView
}
func transitionSourceBackgroundColor() -> UIColor! {
return UIColor.whiteColor()
}
func transitionDestinationImageViewFrame() -> CGRect {
return imageViewFrame()
}
func zoomTransitionAnimator(animator: RMPZoomTransitionAnimator!, didCompleteTransition didComplete: Bool, animatingSourceImageView imageView: UIImageView!) {
}
}
Hi
I'm trying to implement this animation in a Swift project. The problem I'm facing is that whenever my destinationController or sourceController is checked in RMPZoomTransitionAnimator.m for conformity to the RMPZoomTransitionAnimating protocol the check always fails, even though I implement the protocol in the controllers.
What is there that I don't know?