Add property control current page update action.
This commit is contained in:
parent
2f4e7642de
commit
75b7424d3f
|
|
@ -82,6 +82,8 @@ typedef NS_ENUM(NSUInteger, XLPagerTabStripDirection) {
|
|||
|
||||
@property (readonly) NSUInteger currentIndex;
|
||||
@property BOOL skipIntermediateViewControllers;
|
||||
// When user scroll the pager, waiting did end decelerating update page index, Default is NO.
|
||||
@property BOOL shouldDidEndDeceleratingUpdatePage;
|
||||
|
||||
-(void)moveToViewControllerAtIndex:(NSUInteger)index;
|
||||
-(void)moveToViewController:(UIViewController *)viewController;
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@
|
|||
_dataSource = self;
|
||||
_lastContentOffset = 0.0f;
|
||||
_skipIntermediateViewControllers = YES;
|
||||
_shouldDidEndDeceleratingUpdatePage = NO;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
|
|
@ -212,13 +213,20 @@
|
|||
return fmodf(self.containerView.contentOffset.x, [self pageWidth]) / [self pageWidth];
|
||||
}
|
||||
|
||||
- (void)updateCurrentPage
|
||||
{
|
||||
NSUInteger currentPage = [self pageForContentOffset:self.containerView.contentOffset.x];
|
||||
if (currentPage != self.currentIndex){
|
||||
self.currentIndex = currentPage;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)updateContent
|
||||
{
|
||||
NSArray * childViewControllers = self.pagerTabStripChildViewControllers;
|
||||
self.containerView.contentSize = CGSizeMake(CGRectGetWidth(self.containerView.bounds) * childViewControllers.count, self.containerView.contentSize.height);
|
||||
NSUInteger currentPage = [self pageForContentOffset:self.containerView.contentOffset.x];
|
||||
if (currentPage != self.currentIndex){
|
||||
self.currentIndex = currentPage;
|
||||
if (!self.shouldDidEndDeceleratingUpdatePage) {
|
||||
[self updateCurrentPage];
|
||||
}
|
||||
|
||||
[childViewControllers enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||
|
|
@ -296,6 +304,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
|
||||
if (self.shouldDidEndDeceleratingUpdatePage) {
|
||||
[self updateCurrentPage];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
|
||||
{
|
||||
if (self.containerView == scrollView && _originalPagerTabStripChildViewControllers){
|
||||
|
|
|
|||
Loading…
Reference in New Issue