我的UITextView
在达到一定行数后变得可滚动。当我向上滚动一段文本时,滚动指示器不会滚动到 UITextView 的顶部,而是滚动到文本容器的顶部。有什么建议吗?
这是我的UITextView
代码:
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
}()
注意滚动指示器;它应该插入顶部。
最佳答案
我使用collectionView,这些代码行对我有用。尝试:
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)
})
关于ios - UITextView滚动指示器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39304594/