UIWebview가 있습니다. 글꼴 크기를 변경하고 싶습니다.글꼴 크기를 변경할 때 UIWebview의 프레임 크기 조정
NSString *jsString = [NSString stringWithFormat:@"document.body.style.webkitTextSizeAdjust= '%d%%'",50];
[t_webview stringByEvaluatingJavaScriptFromString:jsString];
문제는 내가 50 %로 폰트 크기를 설정하면,있는 UIWebView의 내용을 아래에 큰 빈 영역이 있다는 것입니다 : 는이를 위해 단순히 자바 스크립트를 사용합니다.
나는 다음과 같은 JS를 실행하여 실제 내용의 크기에 맞게 높이에 내 웹보기의 크기를 조정하려고 노력하지만 항상 100 % 텍스트의 높이가 아니라 50 % 실제 하나를 반환
NSLog(@"font size: %i%%",theHeightIWant);
NSString* t_height = [t_webview stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight"];
NSLog(@"height before: %@",t_height);
NSString *jsString = [NSString stringWithFormat:@"document.body.style.webkitTextSizeAdjust= '%d%%'",theHeightIWant];
[t_webview stringByEvaluatingJavaScriptFromString:jsString];
t_height = [t_webview stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight"];
NSLog(@"height after: %@",t_height);
을
---- 로그 ------
font size: 95%
height before: 932
height after: 932
font size: 90%
height before: 932
height after: 932
font size: 85%
height before: 932
height after: 932
내가 대신 document.body.offsetHeight의 document.documentElement.scrollHeight을 사용하려고하지만,이 중 하나가 작동하지 않습니다.
아무도 도와 줄 수 있습니까? 감사.
NSString* t_html = [NSString stringWithFormat:@"<html><body>%@</body></html>",t_htmlPharmaco];
[webview loadHTMLString:t_html baseURL:[[NSBundle mainBundle] bundleURL]];
버그가 사라졌지 만 이유를 모르겠습니다 ..... 계속 하시겠습니까? – Imotep
해결책을 얻었습니까? ? 나는 똑같은 문제에 직면 해있다. @Imotep –
내가 기억하지 못했던 것에서 나는 어떤 빈 공간을 남겨두고 선택의 여지가 없다는 것을 기억한다. 그러나 지금부터 3 년이 지났습니다. 잘못된 것일 수 있으며 더 이상 소스 코드에 액세스하여 확인할 수 없습니다. – Imotep