iOS 调用系统相册拍照时显示英文问题

999 阅读1分钟

在调用系统相册拍照的时候,在选择照片的时候,发现用的都是英文,效果如下:

43121510210675_.pic.jpg

我们想把那个Retake 和Use Photo 改为对应的汉字,先来一种最笨的方法,最后在来个高级的方法,最笨的办法当然是我们找到这两个按钮,修改他们的文字,改成我们希望的文字,这个是可以随便设置的,不叨叨 直接上代码!

方法一

在下面的代理方法找到对应的按钮

-(void)navigationController:(UINavigationController*)navigationController willShowViewController:(UIViewController*)viewController animated:(BOOL)animated{
UIView *PLCropOverlay = [self findView:viewController.view withName:@"PLCropOverlay"];
[PLCropOverlay setValue:@"选择" forKey:@"_defaultOKButtonTitle"];
UIView *PLCropOverlayBottomBar = [self findView:PLCropOverlay withName:@"PLCropOverlayBottomBar"];
UIView *PLCropOverlayPreviewBottomBar = [self findView:PLCropOverlayBottomBar withName:@"PLCropOverlayPreviewBottomBar"];
UIButton *userButton = PLCropOverlayPreviewBottomBar.subviews.lastObject;
UIButton *cancleButton = PLCropOverlayPreviewBottomBar.subviews.firstObject;
[userButton setTitle:@"选择" forState:UIControlStateNormal];
[cancleButton setTitle:@"取消" forState:UIControlStateNormal];

}

// 通过名字找到对应的视图

-(UIView *)findView:(UIView *)aView withName:(NSString *)name {
if ([name isEqualToString:NSStringFromClass(aView.class)]){
    return aView;
}
for (UIView *view in aView.subviews) {
    if ([name isEqualToString:NSStringFromClass(view.class)]) {
    return view;
}
}
return nil;}

其中那个userButton 和cancleButton对应那个选择按钮和取消按钮,具体要设置什么文字就看你们的产品汪了

效果如下:

11E0E3258E8BA4DC9B287C2B0B0E6092.jpg

###方法二

如果没有特别要求,那就用系统的文字,需要在info.plist 里面填加一个key表示app 使用系统的语言,keyLocalized resources can be mixed 设置为YES 就可以了

C4542F78-D2A8-4805-8E8E-E5C7AE8DFC6B.png

最终的效果如下:

841510211540_.pic.jpg