2011-10-31 54 views
0

我想要將選定的行文本從第一個選項卡的表格視圖傳遞到第二個選項卡的視圖標籤。我嘗試這一點,但它不工作:S stringdir是一個的NSString在firstviewcontroller的表視圖和tabBarController的secondviewcontroller之間傳遞數據

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
SecondViewController *detailViewController = [[SecondViewController alloc]initWithNibName:@"SecondView" bundle:nil]; 
// ... 
// Pass the selected object to the new view controller. 
[self.navigationController pushViewController:detailViewController animated:YES]; 
detailViewController.stringdir= [ws2.CustomerName objectAtIndex:[indexPath row]]; 
NSLog(@"şişşşt %@ ", detailViewController.stringdir); 

[detailViewController release]; 
} 

回答

0

移動detailViewController.stringdir = ...你推視圖控制器導航控制器堆棧之前。

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

detailViewController.stringdir= [ws2.CustomerName objectAtIndex:[indexPath row]]; 
NSLog(@"şişşşt %@ ", detailViewController.stringdir); 

// Pass the selected object to the new view controller. 
[self.navigationController pushViewController:detailViewController animated:YES]; 

[detailViewController release]; 
} 
+0

它仍然沒有工作:S這可能是因爲不是導航控制器? –

+0

NSLog是否按預期正確打印它。你是如何在secondViewController中的SecondViewController – ARC

+0

中設置你的stringdir屬性的viewDidLoad enyakinfirma.text = stringdir;我可以用nslog看到detailViewController.stringdir的值。這是我選擇的。 –

相關問題