I am working with a Navigation-based Application. It parses a feed and show data in a tableView. in my main tableView i want to insert a UIWebView in the end. is it possible to make that tableView little bit small and put a UIWebView after that? Thanx
3 Answers
the navigation based application template uses an UITableViewController. When you change this class into the more generic UIViewController and add your tableView and webview you can do it.
change
@interface RootViewController : UITableViewController {
}
@end
into
@interface RootViewController : UIViewController {
UITableView *tableView;
UIWebView *webView;
}
@property (nonatomic, retain) IBOutlet UITableView *tableView;
@property (nonatomic, retain) IBOutlet UIWebView *webView;
@end
then open the RootViewController.xib in interface builder.
- Delete the tableView.
- Add a View from the Library.
- Control-Click-Drag from the file owner onto the view, and select the view outlet.
- Add a TableView into the view. Resize it to your needs.
- Control-Click-Drag from file owner onto tableview. select tableView outlet.
- CC-Drag from the tableview to the file owner, select delegate and datasource.
- Add the UIWebView. By now you should know how to do it.

- 89,811
- 20
- 225
- 247
-
yup its working fine. thanx. but there is one problem. when i click on some cell its DetailView shows its detail. and when i go back then that cell which i clicked remains blue. like when u click some cell and it becomes blue. how can i get rid of that blue color when i go back to main tableView. thanx – Piscean Mar 02 '11 at 10:49
-
you could add `[tableView deselectRowAtIndexPath:indexPath animated:YES];` to your didSelect... method – Matthias Bauch Mar 02 '11 at 10:52
Yes it's possible try to insert subview at index 0
UITableViewCell *cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"cell"] autorelease];
UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, cell.frame.size.width, cell.frame.size.height)];
NSString *html = @"some string";
[webview loadHTMLString:html baseURL:nil];
[webview setBackgroundColor:[UIColor clearColor]];
[webview setOpaque:NO];
[cell insertSubview:webview atIndex:0];
return cell;

- 122
- 4
I don't think you can limit the height of the UITableView in order to append a UIWebView after it. But you can always place a UIWebView in front of the UITableView, in your view hierarchy, if this suites you-- but it will be visible in your screen at all times, i.e. not after scrolling down to the end of your table.
If you need to scroll down and then show the web view, maybe you can place it inside a table view cell (the last one, obviously).

- 304
- 3
- 7
-
its ok if its visible all the times. but i want it at the end of the screen like a toolbar. how can i place UIWebView in front of my UITableView? – Piscean Mar 01 '11 at 19:10
-
You can absolutely set the frame of the UITableView object to be whatever you want to suit your needs. You can have UITableViews together with other UIKit elements in the same view controller. – Bogatyr Mar 02 '11 at 07:16