2011-10-31 52 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的值。这是我选择的。 –

相关问题