Skip to content
This repository was archived by the owner on Apr 16, 2021. It is now read-only.

Fixed now will iter to find the (FlipboardNavigationController) parentviewcontroller #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
28 changes: 17 additions & 11 deletions Classes/FlipBoardNavigationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ - (void) popViewControllerWithCompletion:(FlipBoardNavigationControllerCompletio

UIViewController *currentVC = [self currentViewController];
UIViewController *previousVC = [self previousViewController];

[previousVC viewWillAppear:NO];
[UIView animateWithDuration:kAnimationDuration delay:kAnimationDelay options:0 animations:^{
currentVC.view.frame = CGRectOffset(self.view.bounds, self.view.bounds.size.width, 0);
Expand All @@ -130,6 +131,7 @@ - (void) popViewControllerWithCompletion:(FlipBoardNavigationControllerCompletio
_blackMask.alpha = 0.0;
} completion:^(BOOL finished) {
if (finished) {
[currentVC.view removeFromSuperview];
[currentVC willMoveToParentViewController:nil];
[self.view bringSubviewToFront:[self previousViewController].view];
[currentVC removeFromParentViewController];
Expand Down Expand Up @@ -228,7 +230,7 @@ - (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecogn
#pragma mark - Handle Panning Activity
- (void) gestureRecognizerDidPan:(UIPanGestureRecognizer*)panGesture {
if(_animationInProgress) return;

CGPoint currentPoint = [panGesture translationInView:self.view];
CGFloat x = currentPoint.x + _panOrigin.x;

Expand All @@ -245,6 +247,7 @@ - (void) gestureRecognizerDidPan:(UIPanGestureRecognizer*)panGesture {

UIViewController * vc ;
vc = [self currentViewController];
[vc viewWillDisappear:YES];
offset = CGRectGetWidth(vc.view.frame) - x;

_percentageOffsetFromLeft = offset/[self viewBoundsWithOrientation:self.interfaceOrientation].size.width;
Expand All @@ -255,7 +258,7 @@ - (void) gestureRecognizerDidPan:(UIPanGestureRecognizer*)panGesture {
// If velocity is greater than 100 the Execute the Completion base on pan direction
if(abs(vel.x) > 100) {
[self completeSlidingAnimationWithDirection:panDirection];
}else {
}else {
[self completeSlidingAnimationWithOffset:offset];
}
}
Expand All @@ -275,6 +278,7 @@ - (void) completeSlidingAnimationWithDirection:(PanDirection)direction {
if(direction==PanDirectionRight){
[self popViewController];
}else {
[[self currentViewController] viewDidAppear:YES];
[self rollBackViewController];
}
}
Expand All @@ -285,6 +289,7 @@ - (void) completeSlidingAnimationWithOffset:(CGFloat)offset{
if(offset<[self viewBoundsWithOrientation:self.interfaceOrientation].size.width/2) {
[self popViewController];
}else {
[[self currentViewController] viewDidAppear:YES];
[self rollBackViewController];
}
}
Expand Down Expand Up @@ -328,16 +333,17 @@ @implementation UIViewController (FlipBoardNavigationController)
- (FlipBoardNavigationController *)flipboardNavigationController
{

if([self.parentViewController isKindOfClass:[FlipBoardNavigationController class]]){
return (FlipBoardNavigationController*)self.parentViewController;
}
else if([self.parentViewController isKindOfClass:[UINavigationController class]] &&
[self.parentViewController.parentViewController isKindOfClass:[FlipBoardNavigationController class]]){
return (FlipBoardNavigationController*)[self.parentViewController parentViewController];
}
else{
return nil;
UIViewController *iter = self.parentViewController;
while (iter) {
if ([iter isKindOfClass:[FlipBoardNavigationController class]]) {
return (FlipBoardNavigationController *)iter;
} else if (iter.parentViewController && iter.parentViewController != iter) {
iter = iter.parentViewController;
} else {
iter = nil;
}
}
return nil;

}

Expand Down