使用swift(IOS应用程序)自动滚动UITextView [英] auto scroll for UITextView using swift (IOS app)

查看:302
本文介绍了使用swift(IOS应用程序)自动滚动UITextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎找不到使用 Swift 自动滚动 UITextView 的正确解决方案。

I cant seem to find a right solution to autoscroll UITextView using Swift.

对于我的应用程序,我收到BT的常量数据,我在 UITextView 上更新它。但是,当 UITextView 将到达最新更新的行时,我将不得不手动滚动。

For my app I am receiving constant data from BT, and I am updating it on a UITextView. However, when the UITextView will reach the latest updated line, I would have to manually scroll.

我是什么我试图实现的是保持最后添加的行到 UITextView 可见。 (使用swift)

What I'm trying to achieve is to keep the last added line to the UITextView visible. (using swift)

推荐答案

这将滚动到 UITextView ,带动画:

let range = NSMakeRange(textView.text.characters.count - 1, 0)
textView.scrollRangeToVisible(range)

这篇关于使用swift(IOS应用程序)自动滚动UITextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆