I'm trying to show my text field when the keyboard pops up. (It's currently being hidden by the keyboard which will make it difficult to use).
I got a snippet from one of the other threads that seemed to be working a couple of months ago, but I had to do a lot of xcode 'Fix-its' on the previous code so now I'm not sure why it's not working.
func keyboardWillShow(notification: NSNotification) {
if let userInfo = notification.userInfo {
if let keyboardHeight = (userInfo[UIKeyboardFrameEndUserInfoKey] as AnyObject).CGRectValue.size.height {
tableView.contentInset = UIEdgeInsetsMake(0, 0, keyboardHeight, 0)
}
}
}
I'm getting an error: "Initializer for conditional binding must have Optional type, not 'CGFloat'.
If you know how to fix the previous code so that it works in Swift 3.0 or even if you have a better solution than the snippet I found, please let me know.
Thanks in advance :)