views:

83

answers:

2

Hey friends,

I am trying to create a UIWebView in UITableView footer. The table is grouped. Actually I am trying to create a hyperlink using UIWebView. For example there should be some text like

Hey folks Contact me

Contact me should be a hyperlink and I want to place this text in UITableView footer. I am unable to figure out how to do it..please guide me guys..if possible please post some sample code or please give me a link for the tutorial..I didn't use IB here to create the webview..I just declared webview in .h file

This is the code I wrote in viewForFooterInSection method

CGRect webFrame = CGRectMake(20,500,buttonView.frame.size.width,buttonView.frame.size.height);  
        webView = [[UIWebView alloc] initWithFrame:webFrame];  
        webView.backgroundColor = [UIColor lightGrayColor];  
        [self.view addSubview:webView];  
        NSString *html = @"<html><head></head><body>Hey Folks Contact Us</br></body></html>";  
        [webView loadHTMLString:html baseURL:[NSURL URLWithString:@"http://www.example.com"]];
A: 

Hopefully relevant: UIButton in UITableView Footer

They are creating a button at the UITableView footer with a UIView so maybe you can implement the same using your UIWebView instead of the UIButton.

Kennzo
thanks for the reply Kennzo..I created buttons for another purpose and its working fine..I am unable to use UIWebView as I think I am doing some mistake in the above code..
racharambola
A: 

For adding a custom footer to a table you have a property - tableFooterView. you need to assign the webView you're creating to this property.

In your table view controller's viewDidLoad method do the following:

if (self.tableView.tableFooterView == nil) {
            // Create your webView (move here your code)
    self.tableView.tableFooterView = yourWebView;
}

This works for me, I create my view from nib file.

Nava Carmon