Unverified Commit a5bea485 authored by 谭真's avatar 谭真 Committed by GitHub

Merge pull request #860 from Lucaziki/master

修改CollectionView回调中的代码书写错误
parents e1c9ec22 2af9fb3e
......@@ -467,7 +467,7 @@ static CGFloat itemMargin = 5;
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
// the cell lead to take a picture / 去拍照的cell
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];
cell.imageView.image = tzImagePickerVc.takePictureImage;
if ([tzImagePickerVc.takePictureImageName isEqualToString:@"takePicture80"]) {
......@@ -487,9 +487,9 @@ static CGFloat itemMargin = 5;
cell.useCachedImage = self.useCachedImage;
TZAssetModel *model;
if (tzImagePickerVc.sortAscendingByModificationDate || !_showTakePhotoBtn) {
model = _models[indexPath.row];
model = _models[indexPath.item];
} else {
model = _models[indexPath.row - 1];
model = _models[indexPath.item - 1];
}
cell.allowPickingGif = tzImagePickerVc.allowPickingGif;
cell.model = model;
......@@ -555,13 +555,13 @@ static CGFloat itemMargin = 5;
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
// take a photo / 去拍照
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;
}
// preview phote or video / 预览照片或视频
NSInteger index = indexPath.row;
NSInteger index = indexPath.item;
if (!tzImagePickerVc.sortAscendingByModificationDate && _showTakePhotoBtn) {
index = indexPath.row - 1;
index = indexPath.item - 1;
}
TZAssetModel *model = _models[index];
if (model.type == TZAssetModelMediaTypeVideo && !tzImagePickerVc.allowPickingMultipleVideo) {
......
......@@ -431,7 +431,7 @@
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
TZAssetModel *model = _models[indexPath.row];
TZAssetModel *model = _models[indexPath.item];
TZAssetPreviewCell *cell;
__weak typeof(self) weakSelf = self;
......
......@@ -131,25 +131,25 @@
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
TZTestCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZTestCell" forIndexPath:indexPath];
cell.videoImageView.hidden = YES;
if (indexPath.row == _selectedPhotos.count) {
if (indexPath.item == _selectedPhotos.count) {
cell.imageView.image = [UIImage imageNamed:@"AlbumAddBtn.png"];
cell.deleteBtn.hidden = YES;
cell.gifLable.hidden = YES;
} else {
cell.imageView.image = _selectedPhotos[indexPath.row];
cell.asset = _selectedAssets[indexPath.row];
cell.imageView.image = _selectedPhotos[indexPath.item];
cell.asset = _selectedAssets[indexPath.item];
cell.deleteBtn.hidden = NO;
}
if (!self.allowPickingGifSwitch.isOn) {
cell.gifLable.hidden = YES;
}
cell.deleteBtn.tag = indexPath.row;
cell.deleteBtn.tag = indexPath.item;
[cell.deleteBtn addTarget:self action:@selector(deleteBtnClik:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == _selectedPhotos.count) {
if (indexPath.item == _selectedPhotos.count) {
BOOL showSheet = self.showSheetSwitch.isOn;
if (showSheet) {
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照",@"去相册选择", nil];
......@@ -158,7 +158,7 @@
[self pushTZImagePickerController];
}
} else { // preview photos or video / 预览照片或者视频
id asset = _selectedAssets[indexPath.row];
id asset = _selectedAssets[indexPath.item];
BOOL isVideo = NO;
if ([asset isKindOfClass:[PHAsset class]]) {
PHAsset *phAsset = asset;
......@@ -178,7 +178,7 @@
vc.model = model;
[self presentViewController:vc animated:YES completion:nil];
} 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.allowPickingGif = self.allowPickingGifSwitch.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