开发者

iphonesdk using tableview and html

im making an application where i have to load my database from html file which is in 开发者_Go百科my resource folder. i have a table view and when i click on a certain cell it will open html file based on that click. can any one help me how to do this. thanks


// create a web view in "cellForRowAtIndexPath"

UIWebView *wv = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,320,480)];
[wv loadHTMLString: << your html >> baseURL: nil];
wv.delegate = self;

// implement the webView delegate

- (void) webViewDidFinishLoad:(UIWebView *)webView {
    [self.view addSubView:webView];  // or push onto the naviation controller
}


I think when you 'didSelectCellAtIndex' in the table view will open a new view controller with the webview. And you have also mapping of each cell with the corresponding html file name. Then in the viewDidLoad method of your next VC, you can use this code, while webView is the outlet pointing to your UIWebView. And htmlFileName is the html file's name.

  [webView loadRequest:[NSURLRequest requestWithURL:
          [NSURL fileURLWithPath:[[NSBundle mainBundle] 
          pathForResource:htmlFileName 
          ofType:@"html"] 
          isDirectory:NO] ] ];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜