I know this question was posted so many times but still I can not change the height of UIWebView
based on its content
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title=@"webview";
[_webView setDelegate:self];
NSString * string = @"<h1>This is HTML string</h1>";
[_webView loadHTMLString:string baseURL:nil];
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
return YES;
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
NSLog(@"start loadinng.......");
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
NSLog(@"finish loading.......");
CGRect frame = _webView.frame;
frame.size.height = 1;
_webView.frame = frame;
CGSize fittingSize = [_webView sizeThatFits:CGSizeZero];
frame.size = fittingSize;
_webView.frame = frame;
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
NSLog(@"Failed to load with error :%@",[error debugDescription]);
}
can anybody help me how can resize my UIWebView
height?