【问题标题】:UITextView has long text, the text is not visible, but the textview occupied a large spaceUITextView有长文字,文字不可见,但是textview占用空间大
【发布时间】:2016-04-13 02:00:49
【问题描述】:

我在我的应用程序中使用UITextView。而UITextView的文字很长,这个textview不能编辑和滚动。我用 Masonry 显示这个 UITextView auto layout。并且当文本比数字长时,文本变得不可见,但仍然占用空间。

【问题讨论】:

  • 这个问题只出现在模拟器上,在我的iPhone6(iOS 9.2)上运行良好
  • 你有截图吗?
  • 我添加了截图。

标签: ios autolayout uitextview


【解决方案1】:

如果您禁用了滚动,您将需要在该文本视图中的每次更改时自行更新布局。否则文本将超出视图框架。

// Something like :

// when you got the view loaded:
self.textView.delegate = self

// Update
- (void)textViewDidChange:(UITextView *)textView {
   // Update masonry:
   [textView mas_remakeConstraints^(MASConstraintMaker *make) {
       make.height.equalTo(@(textView.intrinsicContentSize.height));
    }];
}

【讨论】:

  • 我已添加此委托,但无法正常工作。我发现这个委托方法从未被调用过
猜你喜欢
  • 1970-01-01
  • 2011-12-05
  • 2018-11-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-13
  • 2020-03-23
  • 1970-01-01
相关资源
最近更新 更多