2012-07-23 78 views
0

我想獲取存儲在我的數據庫中的表格視圖的值,我成功了,現在我的表格視圖有URL它的值,我想要的是當我點擊特定單元格的值時細胞去我的UIWebView,它加載。表視圖將數據庫中的值傳遞給UIWebView?

爲此,我製作了一個導航控制器,每當選擇任何一行時,我都會推動它。

我粘貼我的代碼在這裏尋求幫助。

對於表視圖:

**- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 1; 
} 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 


    return [appdelegate.tablearr count]; 


} 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 


    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Simple"]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Simple"]autorelease]; 
     cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    } 
    NSDictionary *rowVals = (NSDictionary*) [appdelegate.tablearr objectAtIndex:indexPath.row]; 

    scanValue = (NSString*) [rowVals objectForKey:@"descrip"]; 
    cell.textLabel.text = scanValue; 

    // Set up the cell 
    return cell; 
} 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    DetailViewController *DVC = [[[DetailViewController alloc]initWithNibName:@"DetailViewController" bundle:nil] autorelease]; 
// DVC.characterNumber = indexPath.row; 
    NSLog(@"%@ PASSING VALUE",scanValue); 
    DVC.detailstr = scanValue; 

    [self.navigationController pushViewController:DVC animated:YES]; 
}** 

在我DETAIL VIEW CONTROLLER,我已經作出了NSString *detailstr,在任何商店從scanValue到來。

**- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 


    SecondViewController *sec = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil] ; 
    NSLog(@"WHAT IS COMING HERE %@",detailstr); 

    NSString *urladdress = detailstr; 
    NSURL *url = [NSURL URLWithString:urladdress]; 
    NSURLRequest *request = [NSURLRequest requestWithURL:url]; 
    [webView loadRequest:request];** 

現在任何人都可以幫助我在代碼的東西,任何幫助,我們會真正幫助我。

+0

請問你能解釋一下你面臨的問題......你沒有解釋你的問題。 – 2012-07-23 12:47:48

+0

如何將表格單元格的值傳遞給UIWeb視圖,以便表格單元格單擊該表格單元格中的值應傳遞到UIWeb視圖中? – 2012-07-23 18:00:02

+0

根據你的老代碼,總是有相同的值發送到下一個視圖,但現在它將按照選擇單元格。請使用我發送的最新密碼\ – 2012-07-24 06:35:22

回答

0

我在didSelectRowAtIndexPath方法中增加了一些行,所以請用新的替換舊的。

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

NSDictionary *rowVals = (NSDictionary*) [appdelegate.tablearr objectAtIndex:indexPath.row]; 

scanValue = (NSString*) [rowVals objectForKey:@"descrip"]; 
NSLog(@"%@ PASSING VALUE",scanValue); 
DVC.detailstr = scanValue; 

[self.navigationController pushViewController:DVC animated:YES];} 
+0

你是DUDE MAN ...非常感謝你... 我需要一個很大的OH幫助..繼續幫助像我這樣的人 謝謝你用我的全部心臟 – 2012-07-25 02:35:31

+0

謝謝, 如果您滿意我的解決方案/建議,然後標記爲接受我的答案..或提出答案 – 2012-07-25 15:11:47

+0

已經做到了:) – 2012-07-26 00:23:23