UIView扩展到内部内容

时间:2019-05-27 11:38:51

标签: ios swift

我有一个返回 File "<ipython-input-1-88d96843a926>", line 1, in <module> import keras File "/root/anaconda3/lib/python3.7/site-packages/keras/__init__.py", line 3, in <module> from . import utils File "/root/anaconda3/lib/python3.7/site-packages/keras/utils/__init__.py", line 6, in <module> from . import conv_utils File "/root/anaconda3/lib/python3.7/site-packages/keras/utils/conv_utils.py", line 9, in <module> from .. import backend as K File "/root/anaconda3/lib/python3.7/site-packages/keras/backend/__init__.py", line 89, in <module> from .tensorflow_backend import * File "/root/anaconda3/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 5, in <module> import tensorflow as tf File "/root/anaconda3/lib/python3.7/site-packages/tensorflow/__init__.py", line 24, in <module> from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import File "/root/anaconda3/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 49, in <module> from tensorflow.python import pywrap_tensorflow File "/root/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module> raise ImportError(msg) ImportError: Traceback (most recent call last): File "/root/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module> from tensorflow.python.pywrap_tensorflow_internal import * File "/root/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module> _pywrap_tensorflow_internal = swig_import_helper() File "/root/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "/root/anaconda3/lib/python3.7/imp.py", line 242, in load_module return load_dynamic(name, filename, file) File "/root/anaconda3/lib/python3.7/imp.py", line 342, in load_dynamic return _load(spec) ImportError: libcuda.so.1: cannot open shared object file: No such file or directory 的函数。我想根据UIView(thirdTextView)中显示多少文本来动态更改UIView(fullView)的大小。我目前的身高设置为200。如何获得“动态身高”?

编辑:到目前为止,已更新代码。仅在将子视图添加到视图时才起作用。我不要这个...

UITextView

2 个答案:

答案 0 :(得分:0)

  • 将textview委托给班级
  • 关于textview的textViewDidChange委托方法,给出高度

在您的情况下,

func textViewDidChange(_ textView: UITextView) {

    thirdTextView.contentSize.height = textView.contentSize.height

}

答案 1 :(得分:0)

只需设置宽度锚点,它将动态扩展到内容的高度。

thirdTextView.widthAnchor.constraint(equalToConstant: 128.0).isActive = true