2016-09-23 2 views
3
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 내용에서 내용의 추가 높이를 얻고 것은 "내가 swift3

새로운 생성 이벤트에 대한 테스터. 테스트 설명에 의해 새로운 생성 이벤트에 대한

테스트 설명 Tester.Testing에 의해 작성된 새 이벤트에 대한 설명 Tester에 의해 작성된 새 이벤트에 대한 설명 Tester.Testing에 의해 작성된 새 이벤트에 대한 설명 Tester.Testing에 의해 작성된 새 이벤트에 대한 설명 작성된 새 이벤트에 대한 설명 테스터 별. ription Tester.Testing에 의해 새로 생성 된 이벤트에 대한 설명 Tester.Testing에 의해 새로 생성 된 이벤트에 대한 설명 Tester에 의해 새로 생성 된 이벤트에 대한 설명. Testing Tester.Testing에 의해 새로 생성 된 이벤트에 대한 설명 Tester.Testing에 의해 새로 생성 된 이벤트에 대한 설명 Tester에 의해 새로 생성 된 이벤트에 대한 설명. Testing Tester.Testing에 의해 새로 생성 된 이벤트에 대한 설명 Tester.Testing에 의해 새로 생성 된 이벤트에 대한 설명 Tester에 의해 새로 생성 된 이벤트에 대한 설명. Testing 테스터에 의한 새로 생성 된 이벤트에 대한 설명. 테스터에 의한 새로 생성 된 이벤트에 대한 설명.

\ n "

+0

미리 감사드립니다. –

+0

동일한 오류가 발생합니다. 제가 제약 조건에서 200을 말했을 때 나는 폭과 높이 1000을 얻었습니다. (: 0, Y : 0, 폭 : 200, 높이 : 200 X) // CGFloat, 더블, 지능 myView.frame = RECT – Imran

+0

는하지의 viewDidLoad에서 나는 다음 줄 하자 RECT = CGRect를 추가했다 일. –

답변

4

또한 당신에게 자동 레이아웃 제약 조건을 반드시 확인하시기 바랍니다 확인

func webViewDidFinishLoad(_ webView: UIWebView) { 

     webView.frame.size = webView.sizeThatFits(CGSize.zero) 
     webView.scrollView.isScrollEnabled = false; // Property available in iOS 5.0 and later 
     var frame = webView.frame; 

     frame.size.width = self.view.frame.width-20;  // Your desired width here. 
     frame.size.height = 1;  // Set the height to a small one. 

     webView.frame = frame;  // Set webView's Frame, forcing the Layout of its embedded scrollView with current Frame's constraints (Width set above). 

     frame.size.height = webView.scrollView.contentSize.height; // Get the corresponding height from the webView's embedded scrollView. 

     webView.frame = frame; 
     fl = webView.frame.size.height 

    } 

WebViewDelegate

를 추가합니다. 이 방법은 잘 작동합니다. 자동 레이아웃이 제대로 설정되지 않은 경우 추가 레이아웃을 얻을 수 있습니다.

0

이 시도

는 NSString contentHeight * = [웹뷰 stringByEvaluatingJavaScriptFromString @"document.body.offsetHeight; "]

INT 높이 = contentHeight integerValue]

webViewDidFinishLoad 메서드 웹보기에 위임자를 설정하고 위의 대리자 메서드를보기 컨트롤러에 구현해야합니다.

(210)
+0

작동하지 않습니다. –