Skip to content

Commit

Permalink
Merge pull request #3 from zonaryFUND/bugfix
Browse files Browse the repository at this point in the history
Bugfix
  • Loading branch information
0x0c committed Nov 18, 2014
2 parents 7b0fbf6 + f3c090d commit b86e704
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Pod/Classes/RDImageViewerController/RDImageViewerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,18 @@ - (void)viewWillAppear:(BOOL)animated
}

if (self.showSlider == YES) {
_pageSlider.value = (CGFloat)pagingView_.currentPageIndex / pagingView_.numberOfPages;
if (pagingView_.direction == RDPagingViewDirectionRight) {
_pageSlider.value = (CGFloat)pagingView_.currentPageIndex / (pagingView_.numberOfPages - 1);
} else {
_pageSlider.value = 1 - (CGFloat)pagingView_.currentPageIndex / (pagingView_.numberOfPages - 1);
}
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *sliderItem = [[UIBarButtonItem alloc] initWithCustomView:_pageSlider];
self.toolbarItems = @[flexibleSpace, sliderItem, flexibleSpace];
currentPageHud_.frame = CGRectMake(self.view.center.x - CGRectGetWidth(currentPageHud_.frame) / 2, CGRectGetHeight(self.view.frame) - CGRectGetHeight(currentPageHud_.frame) - 50 * (self.toolbarItems.count > 0) - 10, CGRectGetWidth(currentPageHud_.frame), CGRectGetHeight(currentPageHud_.frame));
}
if (self.showPageNumberHud == YES) {
currentPageHudLabel_.text = [NSString stringWithFormat:@"%d/%ld", pagingView_.currentPageIndex, (long)pagingView_.numberOfPages];
currentPageHudLabel_.text = [NSString stringWithFormat:@"%ld/%ld", (long)(pagingView_.currentPageIndex + 1), (long)pagingView_.numberOfPages];
[self.view addSubview:currentPageHud_];
}
}
Expand Down Expand Up @@ -227,7 +231,11 @@ - (NSInteger)pageIndex

- (void)setPageIndex:(NSInteger)pageIndex
{
self.pageSlider.value = (CGFloat)pageIndex / pagingView_.numberOfPages;
if (pagingView_.direction == RDPagingViewDirectionRight) {
_pageSlider.value = (CGFloat)pagingView_.currentPageIndex / (pagingView_.numberOfPages - 1);
} else {
_pageSlider.value = 1 - (CGFloat)pagingView_.currentPageIndex / (pagingView_.numberOfPages - 1);
}

[pagingView_ scrollAtPage:pageIndex];
}
Expand Down

0 comments on commit b86e704

Please sign in to comment.