ios - UITableView 中的 UITextView 在模拟器上运行时消失

标签 ios objective-c uitableview uitextview

我有一个 UITableView,里面有一个 UITextView。当我在模拟器上运行它时,textView 消失了。这里有一些图片来说明发生了什么:

Storyboard: enter image description here

(textView 为绿色。)

enter image description here (textViews 约束)

当我在模拟器上运行它时:

enter image description here (textView 消失了。)

textView 的高度是动态的。所以我尝试创建一个与“大于或等于”相关的高度约束,并且 textView 的高度没有改变。

(注意:当我添加一个 textField(不是 textView)时,它工作正常。)

Question:

Why does the textView disappear when I run it on the simulator, and how can I fix it?

最佳答案

如果您将 UITextView 设置为“不可”滚动:

[textView setScrollEnabled:NO];

它将能够计算固有尺寸,从而允许自动布局自行移动其他元素,然后由您来正确设置约束。

关于ios - UITableView 中的 UITextView 在模拟器上运行时消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29041668/

相关文章:

objective-c - iOS:UIPopoverController 内的人物选择器,搜索键盘扭曲弹出框

ios - 如何删除 UITableView 中的箭头

iphone - 按下 UIBarButton 时 UIAction 表不会消失

ios - UIWebView 并保持事件状态?

ios - iPad编程,有什么方法可以编程反转颜色?

ios - iOS 中的黑色临时警告框

ios - 使用 dispatch_after 做一些相对于其他事情何时完成的事情

iphone - UINavigationController 逻辑中 searchDisplayController.searchResultsTableView 的行为

ios - 更改 AVPlayer 当前项目(项目 url)并开始播放

ios - Xcode 6 中的错误 - View Controller 没有名为( subview )的导出