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 ta开发者_运维问答bleView little bit small and put a UIWebView after that? Thanx
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.
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;
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).
精彩评论