我正在尝试使用以下代码通过 segues 传递数据:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"exerciseDetailDescription"]) {
SoulExerciseDetailQuarViewController *destination = segue.destinationViewController;
if ([destination respondsToSelector:@selector(setOverview:)]) {
NSDictionary *overview = @{@"name" : [_exercise objectForKey:@"name"], @"longDescription" : [_exercise objectForKey:@"longDescription"]};
[destination setValue:overview forKey:@"overview"];
}
}
else if ([segue.identifier isEqualToString:@"exerciseDetailGear"]) {
SoulExerciseDetailTriaViewController *destination = segue.destinationViewController;
if ([destination respondsToSelector:@selector(setSelectedGearString:)]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
NSString *selectedGearString = cell.detailTextLabel.text;
[destination setValue:selectedGearString forKey:@"selectedGearString"];
}
}
else if ([segue.identifier isEqualToString:@"exerciseDetailCategory"]) {
SoulExerciseDetailDuaViewController *destination = segue.destinationViewController;
if ([destination respondsToSelector:@selector(setSelectedCategoryString:)]) {
NSLog(@"Go");
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
NSString *selectedCategoryString = cell.detailTextLabel.text;
[destination setValue:selectedCategoryString forKey:@"selectedCategoryString"];
}
}}
因此,如果它响应在 segue 的目的地中找到的设置器,则它允许传输数据。
奇怪的是第一个响应正确,但在第二个和第三个中,它说目标视图控制器没有响应那些设置器
例如,在第三个中没有显示 nslog。