【发布时间】:2016-09-23 06:10:12
【问题描述】:
EventWebView.frame.size = EventWebView.sizeThatFits(CGSize.zero)
EventWebView.scrollView.isScrollEnabled = false;
var frame = EventWebView.frame;
frame.size.width = EventTableView.frame.size.width-40; // Your desired width here.
frame.size.height = 1; // Set the height to a small one.
EventWebView.frame = frame; // Set webView's Frame, forcing the Layout of its embedded scrollView with current Frame's constraints (Width set above).
frame.size.height = EventWebView.scrollView.contentSize.height; // Get the corresponding height from the webView's embedded scrollView.
heightConstraint.constant = frame.size.height
我的 HTML 内容是 "
Tester 新创建的事件的测试描述。测试人员新创建的事件的测试说明。测试人员新创建的事件的测试说明。测试人员对新创建的事件的测试描述。测试 Tester.Testing 新创建事件的描述 Tester.Testing 测试新创建事件的描述。测试 Tester.Testing 新创建事件的描述 Tester.Testing 测试新创建事件的描述。测试 Tester.Testing 新创建事件的描述 Tester.Testing 测试新创建事件的描述。测试 Tester.Testing 新创建事件的描述 Tester.Testing 测试新创建事件的描述。测试人员新创建事件的测试说明。测试人员新创建事件的测试说明。
\n"
【问题讨论】:
-
我遇到了同样的错误。当我在约束中说 200 时,我得到了 1000 的宽度和高度。在 viewDidLoad 我必须添加以下行 let rect = CGRect(x: 0, y: 0, width: 200, height: 200) // CGFloat, Double, Int myView.frame = rect
-
@Imran 请检查您的自动布局约束。我的问题在于自动布局约束。
标签: ios iphone uiwebview swift3