I have some instance of UITextView
and I want this textView
to occupy all empty vertical space when keyboard is shown. The problem is that I do not know what height will keyboard take as it has predictive bar in iOS 8 and its actual height can be changed by user when keyboard was already shown. I do not want to change textView
's autocorrectionType
. I am fine with that bar, just want to handle it in correct way.
So the question: Is there any possibility to know if this bar is visible or not? Is there any was to trigger user swipe to show/hide this bar?
Thanks in advance.
Use predictive textTap Keyboard Settings, then turn on Predictive. Or go to Settings > General > Keyboard, and turn Predictive on or off.
As you type text on the iPhone keyboard, you see predictions for your next word, emoji that could take the place of your word, and other suggestions based on your recent activity and information from your apps (not available for all languages).
The Predictive text feature suggests or corrects words as you type text on the Samsung keyboard. This allows you to enter text quickly and easily by suggesting and changing words as you type.
Step 1: Open the Settings app on your iPhone and navigate to the General section. Step 2: Now, tap on Keyboard. Step 3: Scroll down and ensure that the toggles next to Check Spelling and Predictive are enabled.
You can change Setting autocorrectionType to UITextAutocorrectionTypeNo on the UITextView (or correction to NO in IB) disables autocorrect as well as the predictive text bar in iOS 8. There doesn't appear to be a way to disable just the predictive bar however.
yourTextView.autocorrectionType = UITextAutocorrectionTypeNo;
Edit:
check this I think it is gonna be helpful
Well you can handle when the user swipe to show/hide the bar(prediction bar) of UIKeyboard,
First step
declare a keyboard notification in viewdidLoad()
and declare a global variable kbSize
float kbSize;
- (void)viewDidLoad
{
kbSize=0.0;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShowNotification:) name:UIKeyboardWillShowNotification object:nil];
--- rest of your code here---
}
Second step
Now in keyboardWillShowNotification() method do the following
#pragma mark - Notifications
- (void)keyboardWillShowNotification:(NSNotification *)aNotification{
NSDictionary *infos = aNotification.userInfo;
NSValue *value = infos[UIKeyboardFrameEndUserInfoKey];
CGRect rawFrame = [value CGRectValue];
CGRect keyboardFrame = [self.view convertRect:rawFrame fromView:nil];
if(kbSize==0.0)
{
kbSize=keyboardFrame.size.height;
NSLog(@"prediction bar is visible");
}
else if(keyboardFrame.size.height<kbSize)
{
NSLog(@"prediction bar is not visible");
--- rest of your code here, how you want to change your view when bar is not visible ---
}
else
{
NSLog(@"prediction bar is visible");
--- rest of your code here, how you want to change your view when bar is visible ---
}
}
Conclusion:- As keyboardWillShowNotification will always fire whenever the user does some editing with your text-fields or whenever user will swipe to hide or show the prediction bar.
So we just have to check the height of keyboard whenever keyboardWillShowNotification
will fire,so if the user swipe the bar to hide then automatically the keyboard height will decrease and we are already storing the height of keyboard in variable kbSize
, we just have to check whether current height of keyboard is less than then the stored kbSize
. So by this way we can check at runtime whether bar is visible or not or user swipe to hide the bar.
You can get the keyboard height by adding an observer:
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillChange:", name: UIKeyboardDidChangeFrameNotification, object: nil)
//Method
func keyboardWillChange(notification: NSNotification){
println(notification.userInfo?.description)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With