Commit 8d95717d authored by tanzhen's avatar tanzhen

自定义TZCollectionView,优化照片列表页的滑动

parent e993595c
{ {
"images" : [ "images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{ {
"idiom" : "iphone", "idiom" : "iphone",
"size" : "29x29", "size" : "29x29",
......
...@@ -106,11 +106,11 @@ ...@@ -106,11 +106,11 @@
- (UIButton *)selectPhotoButton { - (UIButton *)selectPhotoButton {
if (_selectImageView == nil) { if (_selectImageView == nil) {
UIButton *selectImageView = [[UIButton alloc] init]; UIButton *selectPhotoButton = [[UIButton alloc] init];
selectImageView.frame = CGRectMake(self.tz_width - 44, 0, 44, 44); selectPhotoButton.frame = CGRectMake(self.tz_width - 44, 0, 44, 44);
[selectImageView addTarget:self action:@selector(selectPhotoButtonClick:) forControlEvents:UIControlEventTouchUpInside]; [selectPhotoButton addTarget:self action:@selector(selectPhotoButtonClick:) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:selectImageView]; [self.contentView addSubview:selectPhotoButton];
_selectPhotoButton = selectImageView; _selectPhotoButton = selectPhotoButton;
} }
return _selectPhotoButton; return _selectPhotoButton;
} }
......
...@@ -18,3 +18,8 @@ ...@@ -18,3 +18,8 @@
@property (nonatomic, copy) void (^backButtonClickHandle)(TZAlbumModel *model); @property (nonatomic, copy) void (^backButtonClickHandle)(TZAlbumModel *model);
@end @end
@interface TZCollectionView : UICollectionView
@end
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
} }
@property CGRect previousPreheatRect; @property CGRect previousPreheatRect;
@property (nonatomic, assign) BOOL isSelectOriginalPhoto; @property (nonatomic, assign) BOOL isSelectOriginalPhoto;
@property (nonatomic, strong) UICollectionView *collectionView; @property (nonatomic, strong) TZCollectionView *collectionView;
@property (nonatomic, strong) UIImagePickerController *imagePickerVc; @property (nonatomic, strong) UIImagePickerController *imagePickerVc;
@end @end
...@@ -122,7 +122,7 @@ static CGSize AssetGridThumbnailSize; ...@@ -122,7 +122,7 @@ static CGSize AssetGridThumbnailSize;
CGFloat top = 44; CGFloat top = 44;
if (iOS7Later) top += 20; if (iOS7Later) top += 20;
CGFloat collectionViewHeight = tzImagePickerVc.maxImagesCount > 1 ? self.view.tz_height - 50 - top : self.view.tz_height - top; CGFloat collectionViewHeight = tzImagePickerVc.maxImagesCount > 1 ? self.view.tz_height - 50 - top : self.view.tz_height - top;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, top, self.view.tz_width, collectionViewHeight) collectionViewLayout:layout]; _collectionView = [[TZCollectionView alloc] initWithFrame:CGRectMake(0, top, self.view.tz_width, collectionViewHeight) collectionViewLayout:layout];
_collectionView.backgroundColor = [UIColor whiteColor]; _collectionView.backgroundColor = [UIColor whiteColor];
_collectionView.dataSource = self; _collectionView.dataSource = self;
_collectionView.delegate = self; _collectionView.delegate = self;
...@@ -719,3 +719,16 @@ static CGSize AssetGridThumbnailSize; ...@@ -719,3 +719,16 @@ static CGSize AssetGridThumbnailSize;
} }
@end @end
@implementation TZCollectionView
- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
if ( [view isKindOfClass:[UIControl class]]) {
return YES;
}
return [super touchesShouldCancelInContentView:view];
}
@end
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