I have a UITableView
and I want to add a UIView
as a footer. This UIView
has a UIWebView
and a UIButton
. I have the following code:
- (void)viewWillAppear:(BOOL)animated {
CGRect frame = CGRectMake(10, 0, 280, 400);
self.webViewContent = [[UIWebView alloc] initWithFrame:frame];
self.webViewContent.delegate = self;
self.webViewContent.hidden = YES;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
UIView *viewA = [[UIView alloc] initWithFrame:CGRectMake(webView.bounds.origin.x, webView.bounds.origin.y, webView.bounds.size.width+20, webView.bounds.size.height + firstFrameY)];
viewA.backgroundColor = [UIColor yellowColor];
[viewA addSubview:self.webViewContent];
[viewA addSubview:linkButton];
[self.emailDetailsTableView setTableFooterView:viewA];
}
The output is that I can see everything except the UIWebView
.
However, if I test the following code
- (void)webViewDidFinishLoad:(UIWebView *)webView {
UIView *viewA = [[UIView alloc] initWithFrame:CGRectMake(webView.bounds.origin.x, webView.bounds.origin.y, webView.bounds.size.width+20, webView.bounds.size.height + firstFrameY)];
viewA.backgroundColor = [UIColor yellowColor];
//[viewA addSubview:self.webViewContent];
[viewA addSubview:linkButton];
[self.emailDetailsTableView setTableFooterView:self.webViewContent];
}
I can see the UIWebView
. Please note that I commented the line where I was adding the UIWebView
to the UIView
. If I uncomment the line, I don't see the UIWebView
!!!
Any ideas concerning what I'm doing wrong?
Thanks.
It is likely that your UIWebView is already on screen somewhere. Indeed, if the webView is not displayed, its HTML is not rendered (like in off-screen rendering) and the
webViewDidFinishLoading
never called.What I would try and do in your case is adding the
viewA
to the table footer and make the button hidden, if you need to show it only after the webView has loaded.If you don't want the webView to occupy a large space in the footer while it is loading, make viewA small in the first place. When the HTML has loaded, change the view size (possibly according to the web page height, if it is ok for your app).
just a suggestion...