Commit 9a7248f7 authored by yuzheng.tz's avatar yuzheng.tz

优化Demo

parent ca920694
...@@ -109,7 +109,6 @@ ...@@ -109,7 +109,6 @@
/// 获取asset的资源类型 /// 获取asset的资源类型
- (TZAssetModelMediaType)getAssetType:(id)asset; - (TZAssetModelMediaType)getAssetType:(id)asset;
/// 缩放图片至新尺寸 /// 缩放图片至新尺寸
- (UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)size; - (UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)size;
......
...@@ -127,6 +127,16 @@ ...@@ -127,6 +127,16 @@
#pragma mark UICollectionView #pragma mark UICollectionView
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
if (_selectedPhotos.count >= self.maxCountTF.text.integerValue) {
return _selectedPhotos.count;
}
if (!self.allowPickingMuitlpleVideoSwitch.isOn) {
for (PHAsset *asset in _selectedAssets) {
if (asset.mediaType == PHAssetMediaTypeVideo) {
return _selectedPhotos.count;
}
}
}
return _selectedPhotos.count + 1; return _selectedPhotos.count + 1;
} }
...@@ -676,9 +686,15 @@ ...@@ -676,9 +686,15 @@
#pragma mark - Click Event #pragma mark - Click Event
- (void)deleteBtnClik:(UIButton *)sender { - (void)deleteBtnClik:(UIButton *)sender {
if ([self collectionView:self.collectionView numberOfItemsInSection:0] <= _selectedPhotos.count) {
[_selectedPhotos removeObjectAtIndex:sender.tag]; [_selectedPhotos removeObjectAtIndex:sender.tag];
[_selectedAssets removeObjectAtIndex:sender.tag]; [_selectedAssets removeObjectAtIndex:sender.tag];
[self.collectionView reloadData];
return;
}
[_selectedPhotos removeObjectAtIndex:sender.tag];
[_selectedAssets removeObjectAtIndex:sender.tag];
[_collectionView performBatchUpdates:^{ [_collectionView performBatchUpdates:^{
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:sender.tag inSection:0]; NSIndexPath *indexPath = [NSIndexPath indexPathForItem:sender.tag inSection:0];
[self->_collectionView deleteItemsAtIndexPaths:@[indexPath]]; [self->_collectionView deleteItemsAtIndexPaths:@[indexPath]];
......
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