开发者

is it possible to put a UIWebView after tableView?

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.

  1. Delete the tableView.
  2. Add a View from the Library.
  3. Control-Click-Drag from the file owner onto the view, and select the view outlet.
  4. Add a TableView into the view. Resize it to your needs.
  5. Control-Click-Drag from file owner onto tableview. select tableView outlet.
  6. CC-Drag from the tableview to the file owner, select delegate and datasource.
  7. 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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜