Skip to content
This repository has been archived by the owner on Nov 10, 2021. It is now read-only.

Commit

Permalink
안정성 향상.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jangsy7883 committed May 30, 2016
1 parent 3215958 commit 190ff91
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 32 deletions.
2 changes: 1 addition & 1 deletion JLFullScreenPageViewController.podspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@version = "1.0.25"
@version = "1.0.26"
Pod::Spec.new do |s|
s.name = "JLFullScreenPageViewController"
s.version = @version
Expand Down
69 changes: 38 additions & 31 deletions JLFullScreenPageViewController/JLPageViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,22 @@ - (void)reloadData
}

UIViewController *viewController = [self viewControllerAtIndex:_currentIndex];
[self.pageViewController setViewControllers:@[viewController]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];

if ([self.delegate respondsToSelector:@selector(pageViewController:didScrollToCurrentPosition:)] )
{
[self.delegate pageViewController:self didScrollToCurrentPosition:_currentIndex];
}
if ([self.delegate respondsToSelector:@selector(pageViewController:didChangeToCurrentIndex:fromIndex:)])
if (viewController)
{
[self.delegate pageViewController:self didChangeToCurrentIndex:_currentIndex fromIndex:NSNotFound];
[self.pageViewController setViewControllers:@[viewController]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];

if ([self.delegate respondsToSelector:@selector(pageViewController:didScrollToCurrentPosition:)] )
{
[self.delegate pageViewController:self didScrollToCurrentPosition:_currentIndex];
}
if ([self.delegate respondsToSelector:@selector(pageViewController:didChangeToCurrentIndex:fromIndex:)])
{
[self.delegate pageViewController:self didChangeToCurrentIndex:_currentIndex fromIndex:NSNotFound];
}
}
}

Expand Down Expand Up @@ -346,7 +350,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N

- (UIViewController *)viewControllerAtIndex:(NSInteger)index
{
if (index < self.viewControllers.count)
if (self.viewControllers.count > 0 && index < self.viewControllers.count)
{
return self.viewControllers[index];
}
Expand All @@ -364,27 +368,30 @@ - (void)setCurrentIndex:(NSUInteger)currentIndex animated:(BOOL)animated
{
if (_currentIndex != currentIndex)
{
_nextIndex = currentIndex;

BOOL isForwards = currentIndex > self.currentIndex;
NSArray *viewControllers = self.pageViewController.viewControllers;
UIViewController *viewController = [self viewControllerAtIndex:currentIndex];

typeof(self) __weak weakSelf = self;

dispatch_async(dispatch_get_main_queue(), ^{
[self.pageViewController setViewControllers:@[viewController]
direction:isForwards ? UIPageViewControllerNavigationDirectionForward : UIPageViewControllerNavigationDirectionReverse
animated:animated
completion:^(BOOL finished)
{
typeof(weakSelf) __strong strongSelf = weakSelf;
[strongSelf pageViewController:strongSelf.pageViewController
didFinishAnimating:animated
previousViewControllers:viewControllers
transitionCompleted:YES];
}];
});

if (viewController)
{
_nextIndex = currentIndex;

typeof(self) __weak weakSelf = self;
BOOL isForwards = currentIndex > self.currentIndex;
NSArray *viewControllers = self.pageViewController.viewControllers;

dispatch_async(dispatch_get_main_queue(), ^{
[self.pageViewController setViewControllers:@[viewController]
direction:isForwards ? UIPageViewControllerNavigationDirectionForward : UIPageViewControllerNavigationDirectionReverse
animated:animated
completion:^(BOOL finished)
{
typeof(weakSelf) __strong strongSelf = weakSelf;
[strongSelf pageViewController:strongSelf.pageViewController
didFinishAnimating:animated
previousViewControllers:viewControllers
transitionCompleted:YES];
}];
});
}

/*
BOOL isForwards = currentIndex > self.currentIndex;
Expand Down

0 comments on commit 190ff91

Please sign in to comment.