My UITextView
becomes scrollable at a certain number of lines. When I scroll up a paragraph of text, the scrolling indicator is not scrolling to the top of the UITextView
but to the top of text container. Any suggestions?
Here's my UITextView
code:
lazy var chatTextField: UITextView = {
let chatText = UITextView()
chatText.scrollIndicatorInsets.top = 0
chatText.contentInset = UIEdgeInsetsMake(-40, 0, 0, 0)
chatText.delegate = self
chatText.backgroundColor = UIColor.clearColor()
chatText.font = UIFont(name: "Arial", size: 16)
chatText.textColor = UIColor(r: 120, g: 128, b: 125)
chatText.translatesAutoresizingMaskIntoConstraints = false
return chatText
}()
Take note of the scrolling indicator; it should be pushing the top part.
I use a collectionView and these lines of code work for me. Try:
dispatch_async(dispatch_get_main_queue(), {self.collectionView!.reloadData()
let indexPath = NSIndexPath(forItem: self.messages.count-1, inSection: 0)
self.collectionView?.scrollToItemAtIndexPath(indexPath, atScrollPosition: .Bottom, animated: true)
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.