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

Commit

Permalink
修正点击翻页操作为 collectionView scrollToItemAtIndexPath:
Browse files Browse the repository at this point in the history
  • Loading branch information
anamewing committed Oct 8, 2017
1 parent 4759c4e commit 34908d2
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions EHenTaiViewer/QJMangaViewController.m
Original file line number Diff line number Diff line change
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 34908d2

Please sign in to comment.