IOS storyboard UITableViewCell 单击传值

来源:互联网 发布:维宏股份人工智能 编辑:程序博客网 时间:2024/06/06 01:34
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{        UITableViewCell *cell = (UITableViewCell*)sender;    NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];       Favorite *favorite = [self.favoriteItems objectAtIndex:indexPath.row];    stopString = favorite.title;    routeString = favorite.subtitle;    UIViewController *destination = segue.destinationViewController;    if ([destination respondsToSelector:@selector(setDelegate:)])    {        [destination setValue:self forKey:@"delegate"];    }    if ([destination respondsToSelector:@selector(setSelection:)])    {        NSString *route = routeString;        NSDictionary *selection1 = [NSDictionary dictionaryWithObjectsAndKeys:route, @"route", stopString, @"stop", nil];        [destination setValue:selection1 forKey:@"selection"];    }}
原创粉丝点击