在iOS中计算PDF内容的高度 [英] Calculate PDF content height in iOS
问题描述
我必须在UIWebView
上呈现PDF文件,但是由于我正在使用UITableView
,所以我无法计算PDF
的实际高度,因此我需要设置具有UIWebView的像元高度. /p>
我可以使用以下代码来计算HTML内容.
CGRect frame = newsWebView.frame;
frame.size.height = 1;
frame.size.height = newsWebView.scrollView.contentSize.height; // Get the corresponding height from the webView's embedded scrollView.
webViewHeight =frame.size.height ;
有什么方法可以计算PDF内容吗?
您可以尝试设置setToToit属性,然后在webViewDidFinishLoad中再次设置UIWebView的框架
- (void)webViewDidFinishLoad:(UIWebView *)webView{
[detailsWebView sizeToFit];
[detailsWebView setFrame:CGRectMake(detailsWebView.frame.origin.x, detailsWebView.frame.origin.y, 300.0, detailsWebView.frame.size.height)];
}
在这里您可以使用此方法根据PDF内容来调整Webview的高度,然后再调整单元格的大小
I have to render PDF file on a UIWebView
, but i am unable to calculate the actual height of the PDF
, since i am using UITableView
so i need to set the cell height which has UIWebView.
I am able to calculate the HTML content using below code.
CGRect frame = newsWebView.frame;
frame.size.height = 1;
frame.size.height = newsWebView.scrollView.contentSize.height; // Get the corresponding height from the webView's embedded scrollView.
webViewHeight =frame.size.height ;
Is there any ways to calculate PDF content hieght??
you can Try this set sizeToFit property and again set Frame of UIWebView in webViewDidFinishLoad
- (void)webViewDidFinishLoad:(UIWebView *)webView{
[detailsWebView sizeToFit];
[detailsWebView setFrame:CGRectMake(detailsWebView.frame.origin.x, detailsWebView.frame.origin.y, 300.0, detailsWebView.frame.size.height)];
}
here you can resize webview height according to your PDF content in this method and subsequently resize cell
这篇关于在iOS中计算PDF内容的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!