我想将选定行的文本传递给另一个视图的标签。但这不起作用。没有推第二视图。我该如何解决这个问题?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
SecondViewController *detailViewController = [[SecondViewController alloc] initWithNibName:@"SecondView" bundle:nil];
// ...
// Pass the selected object to the new view controller.
NSUInteger row2 = [indexPath row];
NSLog(@"rowden %i",row2);
denemelik=row2;
NSLog(@"kontrol %i",denemelik);
[self.navigationController pushViewController:detailViewController animated:YES];
detailViewController.stringdir= [ws2.CustomerName objectAtIndex:[indexPath row]];
NSLog(@"hoff %@", [ws2.CustomerName objectAtIndex:[indexPath row]]);
NSLog(@"kontrol2 %@",ws2.CustomerName);
[detailViewController release];
}
在我的secondViewController.m viewDidLoad中我将'stringdir'设置为标签的文本:
enyakinfirma.text = stringdir;
答案 0 :(得分:0)
您只需要在
周围交换这两行代码detailViewController.stringdir= [ws2.CustomerName objectAtIndex:[indexPath row]];
[self.navigationController pushViewController:detailViewController animated:YES];
您应该在调用navigationController之前设置该值。至少这就是我在做的事情。