【发布时间】:2014-07-05 15:39:01
【问题描述】:
我的应用目前具有以下布局:
导航控制器 -> UIViewController -> UIViewController -> UIViewController
我可以使用 segue 在控制器之间移动。
当我尝试在控制器之间传递一些数据时会出现问题。
这在从第一个视图控制器转到第二个视图控制器时有效。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self performSegueWithIdentifier:@"OpenMatch" sender:nil];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"OpenMatch"]) {
NSIndexPath *indexPath = [self.matchesListView indexPathForSelectedRow];
SingleMatchViewController *destViewController = segue.destinationViewController;
MatchData *match = [self.matchesArray objectAtIndex:indexPath.row];
destViewController.matchId = match.objectId;
destViewController.matchTitle = match.matchDescription;
}
}
现在从第二个到第三个 uiviewcontroller 我有类似的代码:
- (IBAction)openStats:(id)sender {
[self performSegueWithIdentifier:@"OpenStats" sender:nil];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"OpenStats"]) {
MatchStatsViewController *destViewController = segue.destinationViewController;
NSLog(@"Opening stats for match : %@",self.matchId);
destViewController.matchId = self.matchId;
destViewController.matchTitle = self.matchTitle;
}
}
它给了我这个错误:
-[UIViewController setMatchId:]: unrecognized selector sent to instance 0x9ba72a0
目标控制器中的属性声明如下:
@property NSString* matchId;
@property NSString* matchTitle;
当最后两行被注释掉时,它就通过了。所以问题出在destViewController.matchId
你能帮我吗?
谢谢。
【问题讨论】:
标签: ios uinavigationcontroller segue