2012-01-09 62 views
1

我想提出一個iPad應用程序,上的UITableViewCell的點擊,一個UIWebView無法加載網頁

我想加載2網頁上的單一的UIWebView此起彼伏,

1的網頁應該來當我加載我應用程序和網頁2號應該來上的tableView細胞的點擊,

所以,我didLoad方法裏面我寫這篇(1網頁),

NSString *urlAddress = @"http://www.google.com"; 

     //Create a URL object. 
    NSURL *url = [NSURL URLWithString:urlAddress]; 

    //URL Requst Object 
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 

    //Load the request in the UIWebView. 
    [webView loadRequest:requestObj]; 

它工精細..

但同樣的WebView在同一頁上的tableView細胞的點擊我要加載另一頁,(第2網頁) 我編寫的代碼加載網頁2日,在

這裏是代碼內容片段在第二個網頁,

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
DatabasesViewController *nextController=[[DatabasesViewController alloc]initWithNibName:@"DatabasesViewController" bundle:nil]; 

     [self.navigationController pushViewController:nextController animated:YES]; 
     [nextController changeProductText:[a objectAtIndex:indexPath.row]]; 
     [nextController changeProductText1:[b objectAtIndex:indexPath.row]]; 
     [nextController changeProductText2:[d objectAtIndex:indexPath.row]]; 

} 

當我選擇裏面的tableView細胞, 它導航到新的觀點,我不想要導航,我想留同一個頁面,我應該在上面的函數做什麼樣的變化上?

在上面的函數changeProductText,changeProductText1,changeProductText2,是三個IBAction和a,b,d是我的數組名稱。

- (IBAction) changeProductText:(NSString *)str{ 

    [email protected]"http://ipad.appel.com/indexcharts.aspx?id="; 
    l2=str; 

    NSString *str1 = [l1 stringByAppendingString:l2]; 

    NSURL *url2=[NSURL URLWithString:str1]; 
    NSURLRequest *req2=[NSURLRequest requestWithURL:url2]; 
    [webView loadRequest:req2]; 
} 

當我的tableView Webview是不顯示的單元格單擊,

我需要清除網頁或重新加載網頁類似的東西?

幫助我男人,提前感謝!

+1

你明白以下幾行? 「DatabasesViewController * nextController = ...」 「[self.navigationController pushViewController ...」 第二個負責導航到新的視圖。如果你不想要它,不要寫它。 如果webview是一個控制器變量,你可以嘗試使用 「self changeProductText:」 而不是「nextController changeProductText:」我不能認爲這是一個答案,如果你沒有真正理解它並需要更多的細節,那麼請讓別人知道你的想法。 – 2012-01-09 05:37:41

+0

夥計..你搖滾它工作正常......但我無法看到網頁,任何解決方案? – Krunal 2012-01-09 06:05:00

+0

我想加載一個網頁點擊單元格的tableView,但無法加載網頁.. :( – Krunal 2012-01-09 06:24:48

回答

0

我想你可以使用UISplitViewController來解決這個問題。

編輯:現在檢查出這樣的代碼..

-(void)tableView:(UITableView *)tableView didSelectedRowAtIndexPath: 
       (NSIndexPath *)indexPath 
      { 
       NSString *urlString = [siteAddress objectAtIndex : indexPath.row]; 
       detailViewController.webView.scalesPageToFit= yes; 
       NSUrl *url = [NSUrlRequest requestWithURL : url]; 
       [detailViewController.webView loadRequest : request]; 
      } 
+0

thanx它的工作..現在,我想加載一個網頁點擊單元格的tableView,但無法加載網頁.. :( – Krunal 2012-01-09 06:25:21

0
[self.navigationController pushViewController:nextController animated:YES]; 

這導航你遠離頁面。它將新視圖推入導航堆棧。擺脫它,如果你不想這樣做。這是一個splitView?