Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Classes/SloppySwiper.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@class SloppySwiper;

@protocol SloppySwiperDelegate <NSObject>
@protocol SloppySwiperDelegate <NSObject, UINavigationControllerDelegate>

@optional
// Return NO when you don't want the TabBar to animate during swiping. (Default YES)
Expand Down
36 changes: 36 additions & 0 deletions Classes/SloppySwiper.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,25 @@ -(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {

#pragma mark - UINavigationControllerDelegate

- (BOOL)respondsToSelector:(SEL)selector {
SEL interfaceOrientationsSelector = @selector(navigationControllerSupportedInterfaceOrientations:);
SEL interfaceOrientationsForPresentationSelector = @selector(navigationControllerPreferredInterfaceOrientationForPresentation:);

// Only use these delegate methods if they can be forwarded
if (selector == interfaceOrientationsSelector || selector == interfaceOrientationsForPresentationSelector) {
return [self.delegate respondsToSelector:selector];
}
return [super respondsToSelector:selector];
}

- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC
{
if (operation == UINavigationControllerOperationPop) {
return self.animator;
}
if ([self.delegate respondsToSelector:@selector(navigationController:animationControllerForOperation:fromViewController:toViewController:)]) {
return [self.delegate navigationController:navigationController animationControllerForOperation:operation fromViewController:fromVC toViewController:toVC];
}
return nil;
}

Expand All @@ -135,6 +149,10 @@ - (void)navigationController:(UINavigationController *)navigationController will
if (animated) {
self.duringAnimation = YES;
}

if ([self.delegate respondsToSelector:@selector(navigationController:willShowViewController:animated:)]) {
[self.delegate navigationController:navigationController willShowViewController:viewController animated:animated];
}
}

- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
Expand All @@ -147,6 +165,24 @@ - (void)navigationController:(UINavigationController *)navigationController didS
else {
self.panRecognizer.enabled = YES;
}

if ([self.delegate respondsToSelector:@selector(navigationController:didShowViewController:animated:)]) {
[self.delegate navigationController:navigationController didShowViewController:viewController animated:animated];
}
}

- (UIInterfaceOrientationMask)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController {
if ([self.delegate respondsToSelector:@selector(navigationControllerSupportedInterfaceOrientations:)]) {
return [self.delegate navigationControllerSupportedInterfaceOrientations:navigationController];
}
return navigationController.supportedInterfaceOrientations;
}

- (UIInterfaceOrientation)navigationControllerPreferredInterfaceOrientationForPresentation:(UINavigationController *)navigationController {
if ([self.delegate respondsToSelector:@selector(navigationControllerPreferredInterfaceOrientationForPresentation:)]) {
return [self.delegate navigationControllerPreferredInterfaceOrientationForPresentation:navigationController];
}
return navigationController.preferredInterfaceOrientationForPresentation;
}

@end