2
질문이 있습니다. Xcode
에는 ViewController
이 포함 된보기>ScrollView
이고 Scrollview 내부는 UIWebView입니다.iOS : UIWebView의 높이 조절 - 이상한 행동
응용 프로그램에서 일부 XML 데이터를 읽고 형식이 지정된 텍스트를 UIWebView
에 붙여 넣습니다. UIWebView-Element
이 다른 요소이기 때문에 동적으로 UIWebView
의 높이를 조정해야합니다.
보기를로드 한 후에도 문제가 없지만 화면을 두 드릴 때보기의 크기는 scrollview
의 스토리 보드 높이가됩니다.
왜? 당신이 프레임을 변경 때마다
- (void)webViewDidFinishLoad:(UIWebView *)aWebView
{
aWebView.scrollView.scrollEnabled = NO; // Property available in iOS 5.0 and later
CGRect frame = aWebView.frame;
frame.size.width = 280; // Your desired width here.
frame.size.height = 1; // Set the height to a small one.
aWebView.frame = frame; // Set webView's Frame, forcing the Layout of its embedded scrollView with current Frame's constraints (Width set above).
frame.size.height = aWebView.scrollView.contentSize.height; // Get the corresponding height from the webView's embedded scrollView.
aWebView.frame = frame; // Set the scrollView contentHeight back to the frame itself.
NSLog(@"size: %f, %f", aWebView.frame.size.width, aWebView.frame.size.height);
// Position URL Label
CGRect frame_label = fachmesseDetailWebsite.frame;
NSLog(@"x: %f", frame_label.origin.x);
NSLog(@"y: %f", frame_label.origin.y);
frame_label.origin.y=aWebView.frame.size.height+115;//pass the cordinate which you want
frame_label.origin.x= 20;//pass the cordinate which you want
fachmesseDetailWebsite.frame= frame_label;
NSLog(@"x: %f", frame_label.origin.x);
NSLog(@"y: %f", frame_label.origin.y);
}
감사 작업이 하나. 다음은 웹 뷰에 콘텐츠를 추가하는 방법입니다. NSString * html = [NSString stringWithFormat : @ "
% @