使用UIWebViewDelegate中提供的- (void)webViewDidFinishLoad:(UIWebView *)aWebView,程式碼如下:
- (void)webViewDidFinishLoad:(UIWebView *)aWebView {
CGRect frame = aWebView.frame;
CGSize fittingSize = [aWebView sizeThatFits:CGSizeZero];
frame.size = fittingSize;
aWebView.frame = frame;
[self setContentSize:CGSizeMake(self.contentSize.width, self.contentSize.height + fittingSize.height)];
}
我在這邊使用的self是個UIScroll,所以直接設定ContentSize的長寬,這樣就行了
參考網址:
How to determine the content size of a UIWebView?
沒有留言:
張貼留言