I want to update the bottom anchor of my textview to a constant equal to the height of the keyboard when it appears so that it doesn't cover the text in the textView. I have a constraint identifier in Main.storyboard set as "bottomTextViewConstraint" for my textView, we well as the following code:
@objc func keyboardWillShow(notification: NSNotification) {
if let keyboardSize = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
print("This prints")
for constraint in self.textView.constraints {
print("This does not print")
if constraint.identifier == "bottomTextViewConstraint" {
constraint.constant = keyboardSize.height
print("This does not print")
}
}
textView.updateConstraints()
}
}
}
self.textView.constraints is nil... It seems that programatically I can't access what I have set up in the storyboard. Any ideas why?
