Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

原因是:有潜在Crash的风险。 #1361

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ + (instancetype)sharedInstance {
dispatch_once(&onceToken, ^{
if (config == nil) {
config = [[TZImagePickerConfig alloc] init];
config.preferredLanguage = nil;
config.preferredLanguage = [NSLocale preferredLanguages].firstObject;
config.gifPreviewMaxImagesCount = 50;
}
});
Expand All @@ -960,9 +960,7 @@ + (instancetype)sharedInstance {
- (void)setPreferredLanguage:(NSString *)preferredLanguage {
_preferredLanguage = preferredLanguage;

if (!preferredLanguage || !preferredLanguage.length) {
preferredLanguage = [NSLocale preferredLanguages].firstObject;
}
#warning 如果你的应用移除了zh-Hant、vi的语言包,移除相应的逻辑 或者 使用下面👇的判断逻辑,以防止Crash
if ([preferredLanguage rangeOfString:@"zh-Hans"].location != NSNotFound) {
preferredLanguage = @"zh-Hans";
} else if ([preferredLanguage rangeOfString:@"zh-Hant"].location != NSNotFound) {
Expand All @@ -972,6 +970,13 @@ - (void)setPreferredLanguage:(NSString *)preferredLanguage {
} else {
preferredLanguage = @"en";
}
/* 判空逻辑
NSString *languagePath = [[NSBundle tz_imagePickerBundle] pathForResource:preferredLanguage ofType:@"lproj"];
NSAssert(languagePath, @"请检查是否缺少了相应的语言文件");
if (!languagePath) {
preferredLanguage = @"en";
}
*/
_languageBundle = [NSBundle bundleWithPath:[[NSBundle tz_imagePickerBundle] pathForResource:preferredLanguage ofType:@"lproj"]];
}

Expand Down