【发布时间】:2015-02-07 06:54:14
【问题描述】:
我有三个表视图 A,B,C 。视图流程是这样的:
表A,点击一行--->表B,点击一行----表C
我正在使用以下方法将数据从主视图A发送到详细视图B。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showDetailFinal"]) {
NSIndexPath *indexPath = [self->ListView_A indexPathForSelectedRow];
DetailView_B *destViewController = segue.destinationViewController;
destViewController.detailStatements = [dataArray objectAtIndex:indexPath.row];
}
}
我再次使用相同的方法将数据从 detailView_B 发送到 moreDetailView_C
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showDetailFinal"]) {
NSIndexPath *indexPath = [self->DetailView_B indexPathForSelectedRow];
More_DetailView_C *destViewController = segue.destinationViewController;
destViewController.detailStatements = [dataArray objectAtIndex:indexPath.row];
}
}
我使用的是模态序列而不是推送。问题是,当我从表 A 转到表 B 时,我看到表 B 中的数据。
但是当我从表 C 回到表 B 时,我没有看到表 B 中的任何数据。
表B中的视图确实加载方法是:
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"the name is %@",detailStatements.name);
// here when I come from table A, name is not null
//but when I come from table C,name is null.
}
是否可以对所有 3 个表视图使用通用的 segue 标识符?
请告诉我可能的处理方法?
【问题讨论】:
-
你能告诉我们你从C带到B的代码吗?C-->B和B-->A。我认为当您从 C 返回到 B 时,您必须创建 tableView B 的新实例。
-
你如何从 C 到 B?
-
通过顶部导航栏中的导航按钮。我没有使用任何代码。
-
我只是 ctrl 将表 C 中的导航按钮拖到表 B 并使其成为模态搜索!!!我从 B 到 A 做了同样的事情。
标签: ios objective-c uitableview