动态UITextView大小基于Swift中的内容 [英] Dynamic UITextView size based on content in Swift

查看:145
本文介绍了动态UITextView大小基于Swift中的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不认为有人可以指导我在正确使用自动布局的同时动态调整UITextView大小的方法吗?使用Swift,即。

I don't suppose someone could guide me on the proper way to dynamically size a UITextView while still using Auto-Layout? Using Swift, that is.

我尝试以编程方式调整底部约束,试图让UITextView拥抱内容。但是我不确定如何获得UITextView内容的高度?

I've tried programmatically adjusting the bottom constraints in attempt to get the UITextView to hug the content. But I'm not sure how to get the height of the content of the UITextView?

我正在尝试将数据加载到UITextView字段中,然后动态调整它们到看起来整洁。

I'm attempting to load data into UITextView fields, then, dynamically adjust them to look neat.

@IBOutlet weak var serviceDescriptionTextViewBottomGuide: NSLayoutConstraint! 

override func viewDidLoad() {

        self.activityName.text = serviceCodes[selectionValue]
        self.serviceDescriptionTextView.text = serviceDescription[selectionValue]
        self.whenToUseDescriptionTextView.text = whenToUseCode[selectionValue]

        self.serviceDescriptionTextViewBottomGuide?.constant += x
    }

推荐答案

禁用滚动,不要放任何可以决定UITextView高度的其他约束。

Disable scrolling and do not put any other constraint that can dictate the height of UITextView.

这篇关于动态UITextView大小基于Swift中的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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