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
Run Code Online (Sandbox Code Playgroud)
我的HTML内容是 “
测试人员为新创建的事件的测试说明。Tester对新创建的事件的测试说明。Tester对新创建的事件的测试说明。测试人员为新创建的事件的测试说明。Tester对新创建的事件的测试说明。Tester对Tester对新创建的事件的说明。Testing对Tester对新创建的事件的说明。Tester对新创建的事件的测试说明。Tester对Tester对新创建的事件的说明。Testing对Tester对新创建的事件的说明。Tester对新创建的事件的测试说明。Tester对Tester对新创建的事件的说明。Testing对Tester对新创建的事件的说明。Tester对新创建的事件的测试说明。Tester对新创建的事件的测试说明。测试人员为新创建的事件的测试说明。Tester对新创建的事件的测试说明。Tester对新创建的事件的测试说明。
\ n“