我试图迫使用户只使用特定的语言(我的设备语言),并阻止这种特定语言上的键盘。不允许他用按钮改变语言。到目前为止,我所做的是添加一个自定义textfield:
@implementation customTextField
- (NSString *)langFromLocale:(NSString *)locale {
NSRange r = [locale rangeOfString:@"_"];
if (r.length == 0) r.location = locale.length;
NSRange r2 = [locale rangeOfString:@"-"];
if (r2.length == 0) r2.location = locale.length;
return [[locale substringToIndex:MIN(r.location, r2.location)]
lowercaseString];
}
- (UITextInputMode *) textInputMode {
NSString *myLanguage = [[NSLocale preferredLanguages]
objectAtIndex:0];
for (UITextInputMode *tim in [UITextInputMode activeInputModes]) {
if ([[self langFromLocale:myLanguage ] isEqualToString:[self
langFromLocale:tim.primaryLanguage]]) return tim;
}
return [super textInputMode];
}
@end这允许我设置键盘的语言,但是当我想删除“更改语言”按钮时,我得到了一个答案,将键盘从默认更改为ascii。因此,现在的语言通常是英语!
等待答案!!谢谢!!
发布于 2017-12-04 13:07:08
此选项在IOS键盘中是不可能的,此按钮在此模式下是默认的。
https://stackoverflow.com/questions/46054852
复制相似问题