一丶事出原因
在使用webview加载链接的时候,需要定位服务,弹出:
@"..." Would Like To Use Your Current Location
Paste_Image.png
需求修改改成中文...
最终效果图:
二丶解决方法
思路:利用Reveal 查看界面:
Paste_Image.png是个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:@"允许使用您当前的位置吗?"];
}
if ([text isEqualToString:key2Str]) {
text = @"不允许";
}
if ([text isEqualToString:key3Str]) {
text = @"好";
}
[self ZB_setText:text];
}
@end
三丶总结
解决办法:
1.保证系统是简体中文
2.info.plist增加
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>zh_CN</string>
</array>
网友评论