我有一個加載內容到這樣一個UIWebView一個UITableView:如何在一個UIWebView檢測到點擊事件
//MainViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
CGRect bounds = [ [ UIScreen mainScreen ] applicationFrame ];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:bounds];
UIWebView *htmlView = [ [ UIWebView alloc ] initWithFrame:[scrollView bounds]];
htmlView.frame = CGRectMake(10,10,280,360);
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[htmlView loadRequest:requestObj];
scrollView.contentSize = [htmlView bounds].size;
[scrollView addSubview:htmlView];
[detailsViewController.view addSubview:htmlView];
[htmlView release];
htmlView = nil;
[scrollView release];
scrollView = nil;
[[self navigationController] pushViewController:detailsViewController animated:YES];
[detailsViewController release];
}
所有這一切被送入UIWebView的遠程內容都來自一個Web服務,我中寫道。第一張截圖是當從標題爲「詞彙表」列表視圖中選擇一個字呈現什麼
這一切是偉大的,直到你點擊一個鏈接,在這種情況下,點擊在「幀」鏈接UIWebView內容。新的內容被加載,但我需要告訴導航欄UIWebView已更改,所以我至少可以更改白色標題文本以匹配新內容。我應該實現哪些UIWebView方法,它們應該放在哪裏?
http://stackoverflow.com/questions/3201264/open-link-from-uiwebview-into-safari -iphone/3201364#3201364 – Nyx0uf 2012-02-08 15:46:55
謝謝!我按照您發佈的鏈接實施了該方法。該方法在事件發生時自動調用,還是需要顯式調用它? – Slinky 2012-02-08 16:01:56
如果將視圖控制器設置爲webview委託,它將被webview自動調用。 – 2012-02-08 16:11:11