UITextView not scrolling in portrait orientation on iOS 11

I have an app whose interface consists of a table view of entries and a text view to view and enter text for that entry. For a newly created entry I can enter text and scroll the text view without problems. But for other entries I have a problem with iOS 11 devices in portrait orientation. When I type enough text to force the text view to scroll, the text view does not scroll. I have to rotate the device to landscape and back to portrait to enable the text view to scroll. I do not have this issue with devices running iOS 9 and iOS 10. The text view is a vanilla text view that has scrolling enabled.


As an experiment I turned off safe area layout guides for the storyboard. Doing this enabled the text view to scroll the first time I selected an entry in the table view. But if I went back to the table view and back to the text view, I got the same behavior I had with the safe area layout guides turned on. The text view would not scroll in portrait orientation unless I rotated to landscape and back to portrait.


The only code I added to Apple's standard UITextView is code to show and hide the keyboard.


@objc func keyboardWasShown(notification: NSNotification) {
     // Scroll the text view so the keyboard doesn't block what's being typed.
     let info = notification.userInfo
     if let keyboardRect = info?[UIKeyboardFrameBeginUserInfoKey] as? CGRect {
          let keyboardSize = keyboardRect.size
          textView.contentInset = UIEdgeInsetsMake(0, 0, keyboardSize.height, 0)
          textView.scrollIndicatorInsets = textView.contentInset
     }  
}
   
@objc func keyboardWillBeHidden(notification: NSNotification) {
     textView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
     textView.scrollIndicatorInsets = textView.contentInset
}


What do I have to do to get the text view to scroll in portrait orientation on iOS 11 devices?

UITextView not scrolling in portrait orientation on iOS 11
 
 
Q