美文网首页
UITextView不能滚动

UITextView不能滚动

作者: 蛋哥是只猫 | 来源:发表于2020-03-23 17:27 被阅读0次

使用UITextView时,进入页面时不能够滚动,但是输入文字换行后可以滚动,解决方法

override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
        let str = self.textView.text
        let h = str.boundingRect(with: size, options: .usesLineFragmentOrigin, attributes: attributes, context:nil).size.height
        self.textView.contentSize = CGSize(width: 0, height: h!+5)
        return super.hitTest(point, with: event)
    }

相关文章

网友评论

      本文标题:UITextView不能滚动

      本文链接:https://www.haomeiwen.com/subject/wdowyhtx.html