@@ -34,7 +34,6 @@ @interface ECSlidingViewController()
34
34
@property (nonatomic , strong ) id <UIViewControllerAnimatedTransitioning> currentAnimationController;
35
35
@property (nonatomic , strong ) id <UIViewControllerInteractiveTransitioning> currentInteractiveTransition;
36
36
@property (nonatomic , strong ) UIView *gestureView;
37
- @property (nonatomic , strong ) UIPanGestureRecognizer *resetPanGesture;
38
37
@property (nonatomic , strong ) NSMapTable *customAnchoredGesturesViewMap;
39
38
@property (nonatomic , assign ) CGFloat currentAnimationPercentage;
40
39
@property (nonatomic , assign ) BOOL preserveLeftPeekAmount;
@@ -175,18 +174,9 @@ - (void)viewDidDisappear:(BOOL)animated {
175
174
}
176
175
}
177
176
178
- - (void )viewWillLayoutSubviews {
179
- if (self.currentOperation == ECSlidingViewControllerOperationNone) {
180
- self.gestureView .frame = [self topViewCalculatedFrameForPosition: self .currentTopViewPosition];
181
- self.topViewController .view .frame = [self topViewCalculatedFrameForPosition: self .currentTopViewPosition];
182
- self.underLeftViewController .view .frame = [self underLeftViewCalculatedFrame ];
183
- self.underRightViewController .view .frame = [self underRightViewCalculatedFrame ];
184
- }
185
- }
186
-
187
177
- (void )viewDidLayoutSubviews {
188
178
if (self.currentOperation == ECSlidingViewControllerOperationNone) {
189
- [self topViewCalculatedFrameForPosition: self .currentTopViewPosition];
179
+ self. gestureView . frame = [self topViewCalculatedFrameForPosition: self .currentTopViewPosition];
190
180
self.topViewController .view .frame = [self topViewCalculatedFrameForPosition: self .currentTopViewPosition];
191
181
self.underLeftViewController .view .frame = [self underLeftViewCalculatedFrame ];
192
182
self.underRightViewController .view .frame = [self underRightViewCalculatedFrame ];
@@ -258,7 +248,6 @@ - (void)setTopViewController:(UIViewController *)topViewController {
258
248
259
249
if ([self isViewLoaded ]) {
260
250
[_topViewController beginAppearanceTransition: YES animated: NO ];
261
- _topViewController.view .frame = [self topViewCalculatedFrameForPosition: self .currentTopViewPosition];
262
251
[self .view addSubview: _topViewController.view];
263
252
[_topViewController endAppearanceTransition ];
264
253
}
@@ -388,14 +377,6 @@ - (UIView *)gestureView {
388
377
return _gestureView;
389
378
}
390
379
391
- - (UIPanGestureRecognizer *)resetPanGesture {
392
- if (_resetPanGesture) return _resetPanGesture;
393
-
394
- _resetPanGesture = [[UIPanGestureRecognizer alloc ] initWithTarget: self action: @selector (detectPanGestureRecognizer: )];
395
-
396
- return _resetPanGesture;
397
- }
398
-
399
380
- (NSMapTable *)customAnchoredGesturesViewMap {
400
381
if (_customAnchoredGesturesViewMap) return _customAnchoredGesturesViewMap;
401
382
@@ -580,6 +561,8 @@ - (ECSlidingViewControllerOperation)operationFromPosition:(ECSlidingViewControll
580
561
- (void )animateOperation : (ECSlidingViewControllerOperation)operation {
581
562
if (![self operationIsValid: operation]) return ;
582
563
if (self.transitionInProgress ) return ;
564
+
565
+ self.view .userInteractionEnabled = NO ;
583
566
584
567
self.transitionInProgress = YES ;
585
568
@@ -697,25 +680,28 @@ - (void)updateTopViewGestures {
697
680
topView.userInteractionEnabled = NO ;
698
681
} else {
699
682
self.gestureView .frame = topView.frame ;
700
- for (UIGestureRecognizer *gesture in self.gestureView .gestureRecognizers ) {
701
- [self .gestureView removeGestureRecognizer: gesture];
702
- }
703
683
704
- if (self.topViewAnchoredGesture & ECSlidingViewControllerAnchoredGesturePanning && self.panGesture .view && self.panGesture .isEnabled ) {
705
- [self .gestureView addGestureRecognizer: self .resetPanGesture];
684
+ if (self.topViewAnchoredGesture & ECSlidingViewControllerAnchoredGesturePanning &&
685
+ ![self .customAnchoredGesturesViewMap objectForKey: self .panGesture]) {
686
+ [self .customAnchoredGesturesViewMap setObject: self .panGesture.view forKey: self .panGesture];
687
+ [self .panGesture.view removeGestureRecognizer: self .panGesture];
688
+ [self .gestureView addGestureRecognizer: self .panGesture];
706
689
if (!self.gestureView .superview ) [self .view insertSubview: self .gestureView aboveSubview: topView];
707
690
}
708
691
709
- if (self.topViewAnchoredGesture & ECSlidingViewControllerAnchoredGestureTapping) {
692
+ if (self.topViewAnchoredGesture & ECSlidingViewControllerAnchoredGestureTapping &&
693
+ ![self .customAnchoredGesturesViewMap objectForKey: self .resetTapGesture]) {
710
694
[self .gestureView addGestureRecognizer: self .resetTapGesture];
711
695
if (!self.gestureView .superview ) [self .view insertSubview: self .gestureView aboveSubview: topView];
712
696
}
713
697
714
698
if (self.topViewAnchoredGesture & ECSlidingViewControllerAnchoredGestureCustom) {
715
699
for (UIGestureRecognizer *gesture in self.customAnchoredGestures ) {
716
- [self .customAnchoredGesturesViewMap setObject: gesture.view forKey: gesture];
717
- [gesture.view removeGestureRecognizer: gesture];
718
- [self .gestureView addGestureRecognizer: gesture];
700
+ if (![self .customAnchoredGesturesViewMap objectForKey: gesture]) {
701
+ [self .customAnchoredGesturesViewMap setObject: gesture.view forKey: gesture];
702
+ [gesture.view removeGestureRecognizer: gesture];
703
+ [self .gestureView addGestureRecognizer: gesture];
704
+ }
719
705
}
720
706
if (!self.gestureView .superview ) [self .view insertSubview: self .gestureView aboveSubview: topView];
721
707
}
@@ -725,7 +711,15 @@ - (void)updateTopViewGestures {
725
711
[self .gestureView removeFromSuperview ];
726
712
for (UIGestureRecognizer *gesture in self.customAnchoredGestures ) {
727
713
UIView *originalView = [self .customAnchoredGesturesViewMap objectForKey: gesture];
728
- if (![originalView.gestureRecognizers containsObject: gesture]) [originalView addGestureRecognizer: gesture];
714
+ if ([originalView isDescendantOfView: self .topViewController.view]) {
715
+ [originalView addGestureRecognizer: gesture];
716
+ }
717
+ }
718
+ if ([self .customAnchoredGesturesViewMap objectForKey: self .panGesture]) {
719
+ UIView *view = [self .customAnchoredGesturesViewMap objectForKey: self .panGesture];
720
+ if ([view isDescendantOfView: self .topViewController.view]) {
721
+ [view addGestureRecognizer: self .panGesture];
722
+ }
729
723
}
730
724
[self .customAnchoredGesturesViewMap removeAllObjects ];
731
725
}
@@ -739,6 +733,7 @@ - (void)detectPanGestureRecognizer:(UIPanGestureRecognizer *)recognizer {
739
733
}
740
734
741
735
[self .defaultInteractiveTransition updateTopViewHorizontalCenterWithRecognizer: recognizer];
736
+ _isInteractive = NO ;
742
737
}
743
738
744
739
#pragma mark - UIViewControllerTransitionCoordinatorContext
@@ -833,9 +828,9 @@ - (void)completeTransition:(BOOL)didComplete {
833
828
if (self.animationComplete ) self.animationComplete ();
834
829
self.animationComplete = nil ;
835
830
836
- [self endAppearanceTransitionForOperation: self .currentOperation isCancelled: [self transitionWasCancelled ]];
837
831
[self setNeedsStatusBarAppearanceUpdate ];
838
832
[self updateTopViewGestures ];
833
+ [self endAppearanceTransitionForOperation: self .currentOperation isCancelled: [self transitionWasCancelled ]];
839
834
840
835
_transitionWasCancelled = NO ;
841
836
_isInteractive = NO ;
@@ -845,6 +840,7 @@ - (void)completeTransition:(BOOL)didComplete {
845
840
self.currentAnimationPercentage = 0 ;
846
841
self.currentOperation = ECSlidingViewControllerOperationNone;
847
842
self.transitionInProgress = NO ;
843
+ self.view .userInteractionEnabled = YES ;
848
844
[UIViewController attemptRotationToDeviceOrientation ];
849
845
}
850
846
@@ -864,10 +860,10 @@ - (UIViewController *)viewControllerForKey:(NSString *)key {
864
860
if (key == UITransitionContextFromViewControllerKey) return self.topViewController ;
865
861
if (key == UITransitionContextToViewControllerKey) return self.underLeftViewController ;
866
862
} else if (self.currentOperation == ECSlidingViewControllerOperationResetFromLeft) {
867
- if (key == UITransitionContextFromViewControllerKey) return self.underLeftViewController ;
863
+ if (key == UITransitionContextFromViewControllerKey) return self.underRightViewController ;
868
864
if (key == UITransitionContextToViewControllerKey) return self.topViewController ;
869
865
} else if (self.currentOperation == ECSlidingViewControllerOperationResetFromRight) {
870
- if (key == UITransitionContextFromViewControllerKey) return self.underRightViewController ;
866
+ if (key == UITransitionContextFromViewControllerKey) return self.underLeftViewController ;
871
867
if (key == UITransitionContextToViewControllerKey) return self.topViewController ;
872
868
}
873
869
@@ -877,10 +873,8 @@ - (UIViewController *)viewControllerForKey:(NSString *)key {
877
873
- (CGRect)initialFrameForViewController : (UIViewController *)vc {
878
874
if (self.currentOperation == ECSlidingViewControllerOperationAnchorLeft) {
879
875
if ([vc isEqual: self .topViewController]) return [self topViewCalculatedFrameForPosition: ECSlidingViewControllerTopViewPositionCentered];
880
- if ([vc isEqual: self .underRightViewController]) return [self underRightViewCalculatedFrame ];
881
876
} else if (self.currentOperation == ECSlidingViewControllerOperationAnchorRight) {
882
877
if ([vc isEqual: self .topViewController]) return [self topViewCalculatedFrameForPosition: ECSlidingViewControllerTopViewPositionCentered];
883
- if ([vc isEqual: self .underLeftViewController]) return [self underLeftViewCalculatedFrame ];
884
878
} else if (self.currentOperation == ECSlidingViewControllerOperationResetFromLeft) {
885
879
if ([vc isEqual: self .topViewController]) return [self topViewCalculatedFrameForPosition: ECSlidingViewControllerTopViewPositionAnchoredLeft];
886
880
if ([vc isEqual: self .underRightViewController]) return [self underRightViewCalculatedFrame ];
@@ -929,6 +923,7 @@ - (void)notifyWhenInteractionEndsUsingBlock:(void(^)(id<UIViewControllerTransiti
929
923
self.coordinatorInteractionEnded = handler;
930
924
}
931
925
926
+ /*
932
927
#pragma mark AutoRotation
933
928
934
929
- (BOOL)shouldAutorotate {
@@ -948,5 +943,5 @@ - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
948
943
return [self.topViewController preferredInterfaceOrientationForPresentation];
949
944
}
950
945
951
-
946
+ */
952
947
@end
0 commit comments