在UITextView上以编程方式禁用iOS8 QuickType键盘
我试图更新iOS8的应用程序,它有一个聊天界面,但是新的Quicktype键盘隐藏了文本视图,所以我想以编程方式或在界面生成器中将其closures。
是否有可能或者只有用户可以在设备设置中closures它?
我知道有一个问题/答案,解决这个问题与UITextfield ,但我需要做一个UITextView 。 
您可以禁用UITextView的键盘build议/自动完成/ 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 } } 
 为了完整起见,我想补充一点,你也可以在Interface Builder做到这一点。 
 要在UITextField或UITextView上禁用键盘build议 – 在“ Attributes Inspector中将“ Correction设置为“ No 。 

我用下面的方法创build了一个UITextView类别类:
 - (void)disableQuickTypeBar:(BOOL)disable { self.autocorrectionType = disable ? UITextAutocorrectionTypeNo : UITextAutocorrectionTypeDefault; if (self.isFirstResponder) { [self resignFirstResponder]; [self becomeFirstResponder]; } } 
 我希望有一个更清洁的方法。 此外,它假设自动更正模式是Default ,对于每个文本视图可能不总是正确的。 
在Swift 2中:
 myUITextField.autocorrectionType = UITextAutocorrectionType.No