在firstviewcontroller的table视图和tabBarController的secondviewcontroller之间传递数据

时间:2011-10-31 13:25:17

标签: objective-c uitabbarcontroller uitableview

我想将选定的行文本从第一个标签的表格视图传递到第二个标签的视图标签。我试试这个但它不起作用:S stringdir是一个nsstring

- (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];
}

1 个答案:

答案 0 :(得分: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];
}