一丶事出原因
在使用webview加載鏈接的時(shí)候,需要定位服務(wù),彈出:
@"..." Would Like To Use Your Current Location
需求修改改成中文...
最終效果圖:
二丶解決方法
思路:利用Reveal 查看界面:
是個(gè)Label;那就簡單了:
#import "UILabel+HYDUI.h"
@implementation UILabel (HYDUI)
+ (void)load{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class selfClass = [self class];
SEL oriSEL = @selector(setText:);
Method oriMethod = class_getInstanceMethod(selfClass, oriSEL);
SEL cusSEL = @selector(ZB_setText:);
Method cusMethod = class_getInstanceMethod(selfClass, cusSEL);
BOOL addSucc = class_addMethod(selfClass, oriSEL, method_getImplementation(cusMethod), method_getTypeEncoding(cusMethod));
if (addSucc) {
class_replaceMethod(selfClass, cusSEL, method_getImplementation(oriMethod), method_getTypeEncoding(oriMethod));
}else {
method_exchangeImplementations(oriMethod, cusMethod);
}
});
}
- (void)ZB_setText:(NSString *)text{
NSString *keyStr = @"Would Like To Use Your Current Location";
NSString *key2Str = @"Don’t Allow";
NSString *key3Str = @"OK";
if ([text containsString:keyStr]) {
NSString *urlStr = [[text componentsSeparatedByString:keyStr] firstObject];
text = [urlStr stringByAppendingString:@"允許使用您當(dāng)前的位置嗎?"];
}
if ([text isEqualToString:key2Str]) {
text = @"不允許";
}
if ([text isEqualToString:key3Str]) {
text = @"好";
}
[self ZB_setText:text];
}
@end
三丶總結(jié)
解決辦法:
1.保證系統(tǒng)是簡體中文
2.info.plist增加
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>zh_CN</string>
</array>