@@ -61,7 +61,7 @@ - (void)viewDidLoad {
6161 [self configCustomNaviBar ];
6262 [self configBottomToolBar ];
6363 self.view .clipsToBounds = YES ;
64- [[NSNotificationCenter defaultCenter ] addObserver: self selector: @selector (didChangeStatusBarOrientationNotification: ) name: UIApplicationDidChangeStatusBarOrientationNotification object: nil ];
64+ [[NSNotificationCenter defaultCenter ] addObserver: self selector: @selector (didChangeStatusBarOrientationNotification: ) name: UIApplicationDidChangeStatusBarOrientationNotification object: nil ];
6565}
6666
6767- (void )setIsSelectOriginalPhoto : (BOOL )isSelectOriginalPhoto {
@@ -78,7 +78,9 @@ - (void)viewWillAppear:(BOOL)animated {
7878 [super viewWillAppear: animated];
7979 [self .navigationController setNavigationBarHidden: YES animated: YES ];
8080 [UIApplication sharedApplication ].statusBarHidden = YES ;
81- if (_currentIndex) [_collectionView setContentOffset: CGPointMake ((self .view.tz_width + 20 ) * _currentIndex, 0 ) animated: NO ];
81+ if (_currentIndex) {
82+ [_collectionView setContentOffset: CGPointMake ((self .view.tz_width + 20 ) * self .currentIndex, 0 ) animated: NO ];
83+ }
8284 [self refreshNaviBarAndBottomBarState ];
8385}
8486
@@ -135,7 +137,7 @@ - (void)configBottomToolBar {
135137 TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController ;
136138 if (_tzImagePickerVc.allowPickingOriginalPhoto ) {
137139 _originalPhotoButton = [UIButton buttonWithType: UIButtonTypeCustom];
138- _originalPhotoButton.imageEdgeInsets = UIEdgeInsetsMake (0 , -10 , 0 , 0 );
140+ _originalPhotoButton.imageEdgeInsets = UIEdgeInsetsMake (0 , [TZCommonTools isRightToLeftLayout ] ? 10 : -10 , 0 , 0 );
139141 _originalPhotoButton.backgroundColor = [UIColor clearColor ];
140142 [_originalPhotoButton addTarget: self action: @selector (originalPhotoButtonClick ) forControlEvents: UIControlEventTouchUpInside];
141143 _originalPhotoButton.titleLabel .font = [UIFont systemFontOfSize: 13 ];
@@ -242,7 +244,7 @@ - (void)configCropView {
242244- (void )viewDidLayoutSubviews {
243245 [super viewDidLayoutSubviews ];
244246 TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController ;
245-
247+
246248 CGFloat statusBarHeight = [TZCommonTools tz_statusBarHeight ];
247249 CGFloat statusBarHeightInterval = statusBarHeight - 20 ;
248250 CGFloat naviBarHeight = statusBarHeight + _tzImagePickerVc.navigationBar .tz_height ;
@@ -294,7 +296,7 @@ - (void)didChangeStatusBarOrientationNotification:(NSNotification *)noti {
294296
295297- (void )select : (UIButton *)selectButton {
296298 TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController ;
297- TZAssetModel *model = _models[_currentIndex ];
299+ TZAssetModel *model = _models[self .currentIndex ];
298300 if (!selectButton.isSelected ) {
299301 // 1. select:check if over the maxImagesCount / 选择照片,检查是否超过了最大个数的限制
300302 if (_tzImagePickerVc.selectedModels .count >= _tzImagePickerVc.maxImagesCount ) {
@@ -305,8 +307,8 @@ - (void)select:(UIButton *)selectButton {
305307 } else {
306308 [_tzImagePickerVc addSelectedModel: model];
307309 if (self.photos ) {
308- [_tzImagePickerVc.selectedAssets addObject: _assetsTemp[_currentIndex ]];
309- [self .photos addObject: _photosTemp[_currentIndex ]];
310+ [_tzImagePickerVc.selectedAssets addObject: _assetsTemp[self .currentIndex ]];
311+ [self .photos addObject: _photosTemp[self .currentIndex ]];
310312 }
311313 if (model.type == TZAssetModelMediaTypeVideo && !_tzImagePickerVc.allowPickingMultipleVideo ) {
312314 [_tzImagePickerVc showAlertWithTitle: [NSBundle tz_localizedStringForKey: @" Select the video when in multi state, we will handle the video as a photo" ]];
@@ -331,13 +333,13 @@ - (void)select:(UIButton *)selectButton {
331333 NSArray *selectedAssetsTmp = [NSArray arrayWithArray: _tzImagePickerVc.selectedAssets];
332334 for (NSInteger i = 0 ; i < selectedAssetsTmp.count ; i++) {
333335 id asset = selectedAssetsTmp[i];
334- if ([asset isEqual: _assetsTemp[_currentIndex ]]) {
336+ if ([asset isEqual: _assetsTemp[self .currentIndex ]]) {
335337 [_tzImagePickerVc.selectedAssets removeObjectAtIndex: i];
336338 break ;
337339 }
338340 }
339- // [_tzImagePickerVc.selectedAssets removeObject:_assetsTemp[_currentIndex ]];
340- [self .photos removeObject: _photosTemp[_currentIndex ]];
341+ // [_tzImagePickerVc.selectedAssets removeObject:_assetsTemp[self.currentIndex ]];
342+ [self .photos removeObject: _photosTemp[self .currentIndex ]];
341343 }
342344 break ;
343345 }
@@ -378,10 +380,10 @@ - (void)doneButtonClick {
378380
379381 // 如果没有选中过照片 点击确定时选中当前预览的照片
380382 if (_tzImagePickerVc.selectedModels .count == 0 && _tzImagePickerVc.minImagesCount <= 0 ) {
381- TZAssetModel *model = _models[_currentIndex ];
383+ TZAssetModel *model = _models[self .currentIndex ];
382384 [_tzImagePickerVc addSelectedModel: model];
383385 }
384- NSIndexPath *indexPath = [NSIndexPath indexPathForItem: _currentIndex inSection: 0 ];
386+ NSIndexPath *indexPath = [NSIndexPath indexPathForItem: self .currentIndex inSection: 0 ];
385387 TZPhotoPreviewCell *cell = (TZPhotoPreviewCell *)[_collectionView cellForItemAtIndexPath: indexPath];
386388 if (_tzImagePickerVc.allowCrop && [cell isKindOfClass: [TZPhotoPreviewCell class ]]) { // 裁剪状态
387389 _doneButton.enabled = NO ;
@@ -393,7 +395,7 @@ - (void)doneButtonClick {
393395 _doneButton.enabled = YES ;
394396 [_tzImagePickerVc hideProgressHUD ];
395397 if (self.doneButtonClickBlockCropMode ) {
396- TZAssetModel *model = _models[_currentIndex ];
398+ TZAssetModel *model = _models[self .currentIndex ];
397399 self.doneButtonClickBlockCropMode (cropedImage,model.asset );
398400 }
399401 } else if (self.doneButtonClickBlock ) { // 非裁剪状态
@@ -433,7 +435,6 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
433435 offSetWidth = offSetWidth + ((self.view .tz_width + 20 ) * 0.5 );
434436
435437 NSInteger currentIndex = offSetWidth / (self.view .tz_width + 20 );
436-
437438 if (currentIndex < _models.count && _currentIndex != currentIndex) {
438439 _currentIndex = currentIndex;
439440 [self refreshNaviBarAndBottomBarState ];
@@ -513,7 +514,7 @@ - (void)dealloc {
513514
514515- (void )refreshNaviBarAndBottomBarState {
515516 TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController ;
516- TZAssetModel *model = _models[_currentIndex ];
517+ TZAssetModel *model = _models[self .currentIndex ];
517518 _selectButton.selected = model.isSelected ;
518519 [self refreshSelectButtonImageViewContentMode ];
519520 if (_selectButton.isSelected && _tzImagePickerVc.showSelectedIndex && _tzImagePickerVc.showSelectBtn ) {
@@ -567,9 +568,13 @@ - (void)refreshSelectButtonImageViewContentMode {
567568}
568569
569570- (void )showPhotoBytes {
570- [[TZImageManager manager ] getPhotosBytesWithArray: @[_models[_currentIndex ]] completion: ^(NSString *totalBytes) {
571+ [[TZImageManager manager ] getPhotosBytesWithArray: @[_models[self .currentIndex ]] completion: ^(NSString *totalBytes) {
571572 self->_originalPhotoLabel .text = [NSString stringWithFormat: @" (%@ )" ,totalBytes];
572573 }];
573574}
574575
576+ - (NSInteger )currentIndex {
577+ return [TZCommonTools isRightToLeftLayout ] ? self.models .count - _currentIndex - 1 : _currentIndex;
578+ }
579+
575580@end
0 commit comments