Skip to content
This repository has been archived by the owner on Dec 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #13 from anamewing/fixTapPage
Browse files Browse the repository at this point in the history
修正连续多次点击翻页之后会翻到空白页面里
  • Loading branch information
kayanouriko committed Oct 9, 2017
2 parents 4759c4e + 34908d2 commit 4ade2ba
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions EHenTaiViewer/QJMangaViewController.m
Expand Up @@ -139,20 +139,22 @@ - (void)tapInWebView {
}

- (void)forwardPage {
CGPoint currOffsize = self.collectionView.contentOffset;
currOffsize.x -= UIScreenWidth();
if (currOffsize.x >= 0) {
[self.collectionView setContentOffset:currOffsize animated:YES];
self.view.userInteractionEnabled = NO;
NSIndexPath *indexNow=[self.collectionView indexPathForCell:[self.collectionView visibleCells][0]];
if (indexNow.item >= 1) {
NSIndexPath *indexPrev=[NSIndexPath indexPathForItem:indexNow.item-1 inSection:indexNow.section];
[self.collectionView scrollToItemAtIndexPath:indexPrev atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES];
} else {
[self show];
}
}

- (void)nextPage {
CGPoint currOffsize = self.collectionView.contentOffset;
currOffsize.x += UIScreenWidth();
if (currOffsize.x <= UIScreenWidth() * (self.items.count - 1)) {
[self.collectionView setContentOffset:currOffsize animated:YES];
self.view.userInteractionEnabled = NO;
NSIndexPath *indexNow=[self.collectionView indexPathForCell:[self.collectionView visibleCells][0]];
if (indexNow.item <= self.items.count-2) {
NSIndexPath *indexNext=[NSIndexPath indexPathForItem:indexNow.item+1 inSection:indexNow.section];
[self.collectionView scrollToItemAtIndexPath:indexNext atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES];
} else {
[self show];
}
}

Expand Down

0 comments on commit 4ade2ba

Please sign in to comment.