Commit 2af9fb3e authored by 王向明's avatar 王向明

修改CollectionView回调中的代码书写错误

parent e1c9ec22
...@@ -467,7 +467,7 @@ static CGFloat itemMargin = 5; ...@@ -467,7 +467,7 @@ static CGFloat itemMargin = 5;
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
// the cell lead to take a picture / 去拍照的cell // the cell lead to take a picture / 去拍照的cell
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (((tzImagePickerVc.sortAscendingByModificationDate && indexPath.row >= _models.count) || (!tzImagePickerVc.sortAscendingByModificationDate && indexPath.row == 0)) && _showTakePhotoBtn) { if (((tzImagePickerVc.sortAscendingByModificationDate && indexPath.item >= _models.count) || (!tzImagePickerVc.sortAscendingByModificationDate && indexPath.item == 0)) && _showTakePhotoBtn) {
TZAssetCameraCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZAssetCameraCell" forIndexPath:indexPath]; TZAssetCameraCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZAssetCameraCell" forIndexPath:indexPath];
cell.imageView.image = tzImagePickerVc.takePictureImage; cell.imageView.image = tzImagePickerVc.takePictureImage;
if ([tzImagePickerVc.takePictureImageName isEqualToString:@"takePicture80"]) { if ([tzImagePickerVc.takePictureImageName isEqualToString:@"takePicture80"]) {
...@@ -487,9 +487,9 @@ static CGFloat itemMargin = 5; ...@@ -487,9 +487,9 @@ static CGFloat itemMargin = 5;
cell.useCachedImage = self.useCachedImage; cell.useCachedImage = self.useCachedImage;
TZAssetModel *model; TZAssetModel *model;
if (tzImagePickerVc.sortAscendingByModificationDate || !_showTakePhotoBtn) { if (tzImagePickerVc.sortAscendingByModificationDate || !_showTakePhotoBtn) {
model = _models[indexPath.row]; model = _models[indexPath.item];
} else { } else {
model = _models[indexPath.row - 1]; model = _models[indexPath.item - 1];
} }
cell.allowPickingGif = tzImagePickerVc.allowPickingGif; cell.allowPickingGif = tzImagePickerVc.allowPickingGif;
cell.model = model; cell.model = model;
...@@ -555,13 +555,13 @@ static CGFloat itemMargin = 5; ...@@ -555,13 +555,13 @@ static CGFloat itemMargin = 5;
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
// take a photo / 去拍照 // take a photo / 去拍照
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (((tzImagePickerVc.sortAscendingByModificationDate && indexPath.row >= _models.count) || (!tzImagePickerVc.sortAscendingByModificationDate && indexPath.row == 0)) && _showTakePhotoBtn) { if (((tzImagePickerVc.sortAscendingByModificationDate && indexPath.item >= _models.count) || (!tzImagePickerVc.sortAscendingByModificationDate && indexPath.item == 0)) && _showTakePhotoBtn) {
[self takePhoto]; return; [self takePhoto]; return;
} }
// preview phote or video / 预览照片或视频 // preview phote or video / 预览照片或视频
NSInteger index = indexPath.row; NSInteger index = indexPath.item;
if (!tzImagePickerVc.sortAscendingByModificationDate && _showTakePhotoBtn) { if (!tzImagePickerVc.sortAscendingByModificationDate && _showTakePhotoBtn) {
index = indexPath.row - 1; index = indexPath.item - 1;
} }
TZAssetModel *model = _models[index]; TZAssetModel *model = _models[index];
if (model.type == TZAssetModelMediaTypeVideo && !tzImagePickerVc.allowPickingMultipleVideo) { if (model.type == TZAssetModelMediaTypeVideo && !tzImagePickerVc.allowPickingMultipleVideo) {
......
...@@ -431,7 +431,7 @@ ...@@ -431,7 +431,7 @@
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
TZAssetModel *model = _models[indexPath.row]; TZAssetModel *model = _models[indexPath.item];
TZAssetPreviewCell *cell; TZAssetPreviewCell *cell;
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
......
...@@ -131,25 +131,25 @@ ...@@ -131,25 +131,25 @@
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
TZTestCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZTestCell" forIndexPath:indexPath]; TZTestCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZTestCell" forIndexPath:indexPath];
cell.videoImageView.hidden = YES; cell.videoImageView.hidden = YES;
if (indexPath.row == _selectedPhotos.count) { if (indexPath.item == _selectedPhotos.count) {
cell.imageView.image = [UIImage imageNamed:@"AlbumAddBtn.png"]; cell.imageView.image = [UIImage imageNamed:@"AlbumAddBtn.png"];
cell.deleteBtn.hidden = YES; cell.deleteBtn.hidden = YES;
cell.gifLable.hidden = YES; cell.gifLable.hidden = YES;
} else { } else {
cell.imageView.image = _selectedPhotos[indexPath.row]; cell.imageView.image = _selectedPhotos[indexPath.item];
cell.asset = _selectedAssets[indexPath.row]; cell.asset = _selectedAssets[indexPath.item];
cell.deleteBtn.hidden = NO; cell.deleteBtn.hidden = NO;
} }
if (!self.allowPickingGifSwitch.isOn) { if (!self.allowPickingGifSwitch.isOn) {
cell.gifLable.hidden = YES; cell.gifLable.hidden = YES;
} }
cell.deleteBtn.tag = indexPath.row; cell.deleteBtn.tag = indexPath.item;
[cell.deleteBtn addTarget:self action:@selector(deleteBtnClik:) forControlEvents:UIControlEventTouchUpInside]; [cell.deleteBtn addTarget:self action:@selector(deleteBtnClik:) forControlEvents:UIControlEventTouchUpInside];
return cell; return cell;
} }
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == _selectedPhotos.count) { if (indexPath.item == _selectedPhotos.count) {
BOOL showSheet = self.showSheetSwitch.isOn; BOOL showSheet = self.showSheetSwitch.isOn;
if (showSheet) { if (showSheet) {
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照",@"去相册选择", nil]; UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照",@"去相册选择", nil];
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
[self pushTZImagePickerController]; [self pushTZImagePickerController];
} }
} else { // preview photos or video / 预览照片或者视频 } else { // preview photos or video / 预览照片或者视频
id asset = _selectedAssets[indexPath.row]; id asset = _selectedAssets[indexPath.item];
BOOL isVideo = NO; BOOL isVideo = NO;
if ([asset isKindOfClass:[PHAsset class]]) { if ([asset isKindOfClass:[PHAsset class]]) {
PHAsset *phAsset = asset; PHAsset *phAsset = asset;
...@@ -178,7 +178,7 @@ ...@@ -178,7 +178,7 @@
vc.model = model; vc.model = model;
[self presentViewController:vc animated:YES completion:nil]; [self presentViewController:vc animated:YES completion:nil];
} else { // preview photos / 预览照片 } else { // preview photos / 预览照片
TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithSelectedAssets:_selectedAssets selectedPhotos:_selectedPhotos index:indexPath.row]; TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithSelectedAssets:_selectedAssets selectedPhotos:_selectedPhotos index:indexPath.item];
imagePickerVc.maxImagesCount = self.maxCountTF.text.integerValue; imagePickerVc.maxImagesCount = self.maxCountTF.text.integerValue;
imagePickerVc.allowPickingGif = self.allowPickingGifSwitch.isOn; imagePickerVc.allowPickingGif = self.allowPickingGifSwitch.isOn;
imagePickerVc.allowPickingOriginalPhoto = self.allowPickingOriginalPhotoSwitch.isOn; imagePickerVc.allowPickingOriginalPhoto = self.allowPickingOriginalPhotoSwitch.isOn;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment