Commit 9434081e authored by yuzheng's avatar yuzheng

适配阿拉伯等语言下从右往左布局的特性

parent 177778f4
......@@ -162,6 +162,9 @@
9038D5901C3974F0007DE549 /* TZTestCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TZTestCell.m; sourceTree = "<group>"; };
903996921F447604005E77C2 /* Photos.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Photos.framework; path = System/Library/Frameworks/Photos.framework; sourceTree = SDKROOT; };
903996941F447609005E77C2 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; };
909DBC95216B981B00926570 /* ar-001 */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "ar-001"; path = "ar-001.lproj/Main.strings"; sourceTree = "<group>"; };
909DBC96216B981B00926570 /* ar-001 */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "ar-001"; path = "ar-001.lproj/LaunchScreen.strings"; sourceTree = "<group>"; };
909DBC97216B981B00926570 /* ar-001 */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "ar-001"; path = "../ar-001.lproj/Localizable.strings"; sourceTree = "<group>"; };
90A74B84203287C200D84C2A /* tz-ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "tz-ru"; path = Localizable.strings; sourceTree = "<group>"; };
90CE84AC1C3A89EF003D0779 /* TZImageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TZImageManager.h; sourceTree = "<group>"; };
90CE84AD1C3A89EF003D0779 /* TZImageManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TZImageManager.m; sourceTree = "<group>"; };
......@@ -498,6 +501,7 @@
Base,
"zh-Hans",
"tz-ru",
"ar-001",
);
mainGroup = 900E65731C2BB8D5003D9A9E;
productRefGroup = 900E657D1C2BB8D5003D9A9E /* Products */;
......@@ -643,6 +647,7 @@
children = (
900E65891C2BB8D5003D9A9E /* Base */,
6D12FC191D66B71E00182C44 /* zh-Hans */,
909DBC95216B981B00926570 /* ar-001 */,
);
name = Main.storyboard;
sourceTree = "<group>";
......@@ -652,6 +657,7 @@
children = (
900E658E1C2BB8D5003D9A9E /* Base */,
6D12FC1A1D66B71E00182C44 /* zh-Hans */,
909DBC96216B981B00926570 /* ar-001 */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
......@@ -660,6 +666,7 @@
isa = PBXVariantGroup;
children = (
90A74B84203287C200D84C2A /* tz-ru */,
909DBC97216B981B00926570 /* ar-001 */,
);
name = Localizable.strings;
sourceTree = "<group>";
......
......@@ -309,6 +309,7 @@
+ (CGFloat)tz_statusBarHeight;
// 获得Info.plist数据字典
+ (NSDictionary *)tz_getInfoDictionary;
+ (BOOL)isRightToLeftLayout;
@end
......
......@@ -862,6 +862,21 @@
}
return infoDict ? infoDict : @{};
}
+ (BOOL)isRightToLeftLayout {
if (@available(iOS 9.0, *)) {
if ([UIView userInterfaceLayoutDirectionForSemanticContentAttribute:UISemanticContentAttributeUnspecified] == UIUserInterfaceLayoutDirectionRightToLeft) {
return YES;
}
} else {
NSString *preferredLanguage = [NSLocale preferredLanguages].firstObject;
if ([preferredLanguage hasPrefix:@"ar-"]) {
return YES;
}
}
return NO;
}
@end
......
......@@ -211,7 +211,7 @@ static CGFloat itemMargin = 5;
if (tzImagePickerVc.allowPickingOriginalPhoto) {
_originalPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
_originalPhotoButton.imageEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
_originalPhotoButton.imageEdgeInsets = UIEdgeInsetsMake(0, [TZCommonTools isRightToLeftLayout] ? 10 : -10, 0, 0);
[_originalPhotoButton addTarget:self action:@selector(originalPhotoButtonClick) forControlEvents:UIControlEventTouchUpInside];
_originalPhotoButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_originalPhotoButton setTitle:tzImagePickerVc.fullImageBtnTitleStr forState:UIControlStateNormal];
......
......@@ -61,7 +61,7 @@
[self configCustomNaviBar];
[self configBottomToolBar];
self.view.clipsToBounds = YES;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangeStatusBarOrientationNotification:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangeStatusBarOrientationNotification:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
}
- (void)setIsSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto {
......@@ -78,7 +78,9 @@
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
[UIApplication sharedApplication].statusBarHidden = YES;
if (_currentIndex) [_collectionView setContentOffset:CGPointMake((self.view.tz_width + 20) * _currentIndex, 0) animated:NO];
if (_currentIndex) {
[_collectionView setContentOffset:CGPointMake((self.view.tz_width + 20) * self.currentIndex, 0) animated:NO];
}
[self refreshNaviBarAndBottomBarState];
}
......@@ -135,7 +137,7 @@
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (_tzImagePickerVc.allowPickingOriginalPhoto) {
_originalPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
_originalPhotoButton.imageEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
_originalPhotoButton.imageEdgeInsets = UIEdgeInsetsMake(0, [TZCommonTools isRightToLeftLayout] ? 10 : -10, 0, 0);
_originalPhotoButton.backgroundColor = [UIColor clearColor];
[_originalPhotoButton addTarget:self action:@selector(originalPhotoButtonClick) forControlEvents:UIControlEventTouchUpInside];
_originalPhotoButton.titleLabel.font = [UIFont systemFontOfSize:13];
......@@ -242,7 +244,7 @@
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
CGFloat statusBarHeight = [TZCommonTools tz_statusBarHeight];
CGFloat statusBarHeightInterval = statusBarHeight - 20;
CGFloat naviBarHeight = statusBarHeight + _tzImagePickerVc.navigationBar.tz_height;
......@@ -294,7 +296,7 @@
- (void)select:(UIButton *)selectButton {
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
TZAssetModel *model = _models[_currentIndex];
TZAssetModel *model = _models[self.currentIndex];
if (!selectButton.isSelected) {
// 1. select:check if over the maxImagesCount / 选择照片,检查是否超过了最大个数的限制
if (_tzImagePickerVc.selectedModels.count >= _tzImagePickerVc.maxImagesCount) {
......@@ -305,8 +307,8 @@
} else {
[_tzImagePickerVc addSelectedModel:model];
if (self.photos) {
[_tzImagePickerVc.selectedAssets addObject:_assetsTemp[_currentIndex]];
[self.photos addObject:_photosTemp[_currentIndex]];
[_tzImagePickerVc.selectedAssets addObject:_assetsTemp[self.currentIndex]];
[self.photos addObject:_photosTemp[self.currentIndex]];
}
if (model.type == TZAssetModelMediaTypeVideo && !_tzImagePickerVc.allowPickingMultipleVideo) {
[_tzImagePickerVc showAlertWithTitle:[NSBundle tz_localizedStringForKey:@"Select the video when in multi state, we will handle the video as a photo"]];
......@@ -331,13 +333,13 @@
NSArray *selectedAssetsTmp = [NSArray arrayWithArray:_tzImagePickerVc.selectedAssets];
for (NSInteger i = 0; i < selectedAssetsTmp.count; i++) {
id asset = selectedAssetsTmp[i];
if ([asset isEqual:_assetsTemp[_currentIndex]]) {
if ([asset isEqual:_assetsTemp[self.currentIndex]]) {
[_tzImagePickerVc.selectedAssets removeObjectAtIndex:i];
break;
}
}
// [_tzImagePickerVc.selectedAssets removeObject:_assetsTemp[_currentIndex]];
[self.photos removeObject:_photosTemp[_currentIndex]];
// [_tzImagePickerVc.selectedAssets removeObject:_assetsTemp[self.currentIndex]];
[self.photos removeObject:_photosTemp[self.currentIndex]];
}
break;
}
......@@ -378,10 +380,10 @@
// 如果没有选中过照片 点击确定时选中当前预览的照片
if (_tzImagePickerVc.selectedModels.count == 0 && _tzImagePickerVc.minImagesCount <= 0) {
TZAssetModel *model = _models[_currentIndex];
TZAssetModel *model = _models[self.currentIndex];
[_tzImagePickerVc addSelectedModel:model];
}
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:_currentIndex inSection:0];
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:self.currentIndex inSection:0];
TZPhotoPreviewCell *cell = (TZPhotoPreviewCell *)[_collectionView cellForItemAtIndexPath:indexPath];
if (_tzImagePickerVc.allowCrop && [cell isKindOfClass:[TZPhotoPreviewCell class]]) { // 裁剪状态
_doneButton.enabled = NO;
......@@ -393,7 +395,7 @@
_doneButton.enabled = YES;
[_tzImagePickerVc hideProgressHUD];
if (self.doneButtonClickBlockCropMode) {
TZAssetModel *model = _models[_currentIndex];
TZAssetModel *model = _models[self.currentIndex];
self.doneButtonClickBlockCropMode(cropedImage,model.asset);
}
} else if (self.doneButtonClickBlock) { // 非裁剪状态
......@@ -433,7 +435,6 @@
offSetWidth = offSetWidth + ((self.view.tz_width + 20) * 0.5);
NSInteger currentIndex = offSetWidth / (self.view.tz_width + 20);
if (currentIndex < _models.count && _currentIndex != currentIndex) {
_currentIndex = currentIndex;
[self refreshNaviBarAndBottomBarState];
......@@ -513,7 +514,7 @@
- (void)refreshNaviBarAndBottomBarState {
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
TZAssetModel *model = _models[_currentIndex];
TZAssetModel *model = _models[self.currentIndex];
_selectButton.selected = model.isSelected;
[self refreshSelectButtonImageViewContentMode];
if (_selectButton.isSelected && _tzImagePickerVc.showSelectedIndex && _tzImagePickerVc.showSelectBtn) {
......@@ -567,9 +568,13 @@
}
- (void)showPhotoBytes {
[[TZImageManager manager] getPhotosBytesWithArray:@[_models[_currentIndex]] completion:^(NSString *totalBytes) {
[[TZImageManager manager] getPhotosBytesWithArray:@[_models[self.currentIndex]] completion:^(NSString *totalBytes) {
self->_originalPhotoLabel.text = [NSString stringWithFormat:@"(%@)",totalBytes];
}];
}
- (NSInteger)currentIndex {
return [TZCommonTools isRightToLeftLayout] ? self.models.count - _currentIndex - 1 : _currentIndex;
}
@end
/* Class = "UITextField"; text = "9"; ObjectID = "37K-cO-hgf"; */
"37K-cO-hgf.text" = "9";
/* Class = "UILabel"; text = "允许选择照片原图"; ObjectID = "7mi-Lf-2N5"; */
"7mi-Lf-2N5.text" = "允许选择照片原图";
/* Class = "UILabel"; text = "允许多选视频/GIF/图片"; ObjectID = "7q9-aI-kbz"; */
"7q9-aI-kbz.text" = "允许多选视频/GIF/图片";
/* Class = "UILabel"; text = "允许拍视频"; ObjectID = "8H2-cq-aUq"; */
"8H2-cq-aUq.text" = "允许拍视频";
/* Class = "UILabel"; text = "单选模式下允许裁剪"; ObjectID = "Ibb-kN-MWC"; */
"Ibb-kN-MWC.text" = "单选模式下允许裁剪";
/* Class = "UILabel"; text = "允许选择Gif图片"; ObjectID = "Ly2-uJ-7DN"; */
"Ly2-uJ-7DN.text" = "允许选择Gif图片";
/* Class = "UILabel"; text = "允许拍照"; ObjectID = "R92-Zn-NWV"; */
"R92-Zn-NWV.text" = "允许拍照";
/* Class = "UILabel"; text = "使用圆形裁剪框"; ObjectID = "TiG-df-jDs"; */
"TiG-df-jDs.text" = "使用圆形裁剪框";
/* Class = "UILabel"; text = "照片按修改时间升序排列"; ObjectID = "UL3-n3-Hmt"; */
"UL3-n3-Hmt.text" = "照片按修改时间升序排列";
/* Class = "UITextField"; text = "4"; ObjectID = "YR1-nJ-q0v"; */
"YR1-nJ-q0v.text" = "4";
/* Class = "UILabel"; text = "每行展示照片张数"; ObjectID = "fbH-6q-oeE"; */
"fbH-6q-oeE.text" = "每行展示照片张数";
/* Class = "UILabel"; text = "把拍照/拍视频按钮放在外面"; ObjectID = "jop-5R-ioj"; */
"jop-5R-ioj.text" = "把拍照/拍视频按钮放在外面";
/* Class = "UILabel"; text = "右上角显示图片选中序号"; ObjectID = "nm2-mT-siy"; */
"nm2-mT-siy.text" = "右上角显示图片选中序号";
/* Class = "UILabel"; text = "照片最大可选张数"; ObjectID = "rK3-1U-kcW"; */
"rK3-1U-kcW.text" = "照片最大可选张数";
/* Class = "UILabel"; text = "允许选择照片"; ObjectID = "vNN-OI-9z1"; */
"vNN-OI-9z1.text" = "允许选择照片";
/* Class = "UILabel"; text = "允许选择视频"; ObjectID = "xCu-D3-IZg"; */
"xCu-D3-IZg.text" = "允许选择视频";
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