|
@@ -132,6 +132,12 @@
|
|
|
preCell.model = model;
|
|
preCell.model = model;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
+
|
|
|
|
|
+ PhotoPreviewCell *preCell = (PhotoPreviewCell *)cell;
|
|
|
|
|
+ [preCell reset];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
#pragma mark - CollectionView DataSource
|
|
#pragma mark - CollectionView DataSource
|
|
|
|
|
|
|
|
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
|
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
|
@@ -151,30 +157,34 @@
|
|
|
#pragma mark - ScrollView Delegate
|
|
#pragma mark - ScrollView Delegate
|
|
|
|
|
|
|
|
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
|
|
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
|
|
|
- CGFloat offsetX = scrollView.contentOffset.x;
|
|
|
|
|
- float idxf = offsetX / CGRectGetWidth(scrollView.frame);
|
|
|
|
|
- int idxi = (int)(offsetX / CGRectGetWidth(scrollView.frame));
|
|
|
|
|
-
|
|
|
|
|
- if (idxf == idxi) {
|
|
|
|
|
- if (idxi == 0) {
|
|
|
|
|
- self.currentIndex = self.photos.count - 1;
|
|
|
|
|
- } else if (idxi == self.photos.count + 1) {
|
|
|
|
|
- self.currentIndex = 0;
|
|
|
|
|
|
|
+ if (scrollView == self.previewContainer) {
|
|
|
|
|
+
|
|
|
|
|
+ CGFloat offsetX = scrollView.contentOffset.x;
|
|
|
|
|
+ float idxf = offsetX / CGRectGetWidth(scrollView.frame);
|
|
|
|
|
+ int idxi = (int)(offsetX / CGRectGetWidth(scrollView.frame));
|
|
|
|
|
+
|
|
|
|
|
+ if (idxf == idxi) {
|
|
|
|
|
+ if (idxi == 0) {
|
|
|
|
|
+ self.currentIndex = self.photos.count - 1;
|
|
|
|
|
+ } else if (idxi == self.photos.count + 1) {
|
|
|
|
|
+ self.currentIndex = 0;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ self.currentIndex = idxi - 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ [self updateIndicator];
|
|
|
} else {
|
|
} else {
|
|
|
- self.currentIndex = idxi - 1;
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- [self updateIndicator];
|
|
|
|
|
- } else {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (idxi == 0) {
|
|
|
|
|
- [self scrollToIndex:self.photos.count];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (idxi == self.photos.count + 1) {
|
|
|
|
|
- [self scrollToIndex:1];
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (idxi == 0) {
|
|
|
|
|
+ [self scrollToIndex:self.photos.count];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (idxi == self.photos.count + 1) {
|
|
|
|
|
+ [self scrollToIndex:1];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|