1

I am working on an iPhone application, where i am opening an URL to my UIWebView. The problem is URL is not loading perfectly. As per my requirement, i need to add UIWebView as footer view of my table. but the problem is after getting the web view content height size from webViewDidFinishLoad method, i am setting frame of my footer view. here is my code :

- (void)webViewDidFinishLoad:(UIWebView *)aWebView {

        aWebView.scrollView.scrollEnabled = NO;
        CGRect frame = aWebView.frame;
        frame.size.height = 1;
        aWebView.frame = frame;
        CGSize fittingSize = [aWebView sizeThatFits:CGSizeZero];
        frame.size = fittingSize;
        aWebView.frame = frame;

        [self setFooterView:fittingSize.height + aWebView.frame.origin.y];
}

-(void)setFooterView:(float)fittingHeight
{
    bottomView.frame = CGRectMake(0, 0, 320, fittingHeight);
    webViewSocial.frame = bottomView.frame;
    [tableView reloadData];
}

But when i am scrolling my table view, then my UIWebView (footer view) is not scrolling completely. Can you please tell me how can i achieve my output. Thanks!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
user2786
  • 656
  • 4
  • 13
  • 35

1 Answers1

1

try to set like this

- (void)webViewDidFinishLoad:(UIWebView *)aWebView {
       CGFloat height = [[self.webView stringByEvaluatingJavaScriptFromString:@"document.height"] floatValue];
       CGFloat width = [[self.webView stringByEvaluatingJavaScriptFromString:@"document.width"] floatValue];
       CGRect frame = self.webView.frame;
       frame.size.height = height;
       frame.size.width = width;
       self.webView.frame = frame;
       self.tableView.tableFooterView = webView;
}
l0gg3r
  • 8,864
  • 3
  • 26
  • 46
  • Thanks for your answer, i have applied your code but the problem is webViewDidFinishLoad is calling one time, so not able to set frame again and again. Please give me any suggestion. – user2786 Sep 25 '14 at 15:08
  • You don't need to set the frame continuously. tableView will render it correctly for you. all you need to do to use native [self.tableView setTableFooterView:aWebView]; (The problem appears because you're using your custom bottomView) – l0gg3r Sep 25 '14 at 15:10
  • okey.. but my table view is not scrolling upto the URL content, some contents are hiding. – user2786 Sep 25 '14 at 15:11
  • also, if there is some custom staff, that you need to continuously apply, - (void)viewDidLayoutSubviews{} and make your customizations, and frame modifications (after invoking [super viewDidLayoutSubviews]) – l0gg3r Sep 25 '14 at 15:12
  • Can you please send your existing code (version with my code), I will try to test and fix it. (You can use pastebin.com) – l0gg3r Sep 25 '14 at 15:17
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/61920/discussion-between-user2786-and-l0gg3r). – user2786 Sep 25 '14 at 15:18