I created delegate and its methods are the same to every VC that it supports. How can I use with out code duplication?
My code
#pragma mark - UIViewControllerTransitioningDelegate
(id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source
{
CircularTransitionAnimator *animator = [CircularTransitionAnimator new];
animator.isPresenting = YES;
self.pointForAnimationOfViewUserPhotos = point;
animator.actionPoint = point;
return animator;
}
-(id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
{
CircularTransitionAnimator *animator = [CircularTransitionAnimator new];
animator.isPresenting = NO;
animator.actionPoint = self.pointForAnimationOfViewUserPhotos;
return animator;
}
您可以使用专用于委托方法的单独类,也可以使用其他所有VC都将继承的视图控制器子类。
As @rounak suggests you can create a separate class dedicated for handling the delegation.
Example
Create an NSObject subclass and adopt UIViewControllerTransitioningDelegate and add & implement the delegate methods.
In you VC assign your new object as the transitioningDelegate
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.