rih*_*ihe 68 xcode objective-c ios ios8
我正在尝试更新iOS8的应用程序,它有一个聊天界面,但新的Quicktype键盘隐藏了文本视图,因此我想以编程方式或在界面构建器中关闭它.
是否可能以某种方式或仅用户可以在设备设置中将其关闭?
我知道有一个问题/答案用a来解决这个问题UITextfield,但我需要用a来解决这个问题UITextView.
mih*_*hai 124
您可以为UITextView禁用键盘建议/自动完成/ QuickType,它可以阻止像4S这样的较小屏幕上的文本,如本例所示
使用以下行:
myTextView.autocorrectionType = UITextAutocorrectionTypeNo;
 
 
而且,如果您只想在特定屏幕上执行此操作,例如定位4S
if([[UIDevice currentDevice]userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
    CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
    if (screenHeight == 568) {
        // iphone 5 screen
    }
    else if (screenHeight < 568) {
       // smaller than iphone 5 screen thus 4s
    }
}
Nik*_*kin 52
为了完整起见,我想补充一点,你也可以这样做Interface Builder.
要禁用设置为的UITextField或UITextView- 中的键盘建议.Attributes InspectorCorrectionNo

我用以下方法创建了一个UITextView类别类:
- (void)disableQuickTypeBar:(BOOL)disable
{
    self.autocorrectionType = disable ? UITextAutocorrectionTypeNo : UITextAutocorrectionTypeDefault;
    if (self.isFirstResponder) {
        [self resignFirstResponder];
        [self becomeFirstResponder];
    }
}
我希望有一个更清洁的方法.此外,它假设自动校正模式Default,对于每个文本视图可能并非总是如此.
| 归档时间: | 
 | 
| 查看次数: | 41500 次 | 
| 最近记录: |