问题:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender;
以上方法会先于
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
因此我们必须在跳转的时候找到点击了那一行cell
可以用以下方法:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
//判断哪条segue
if ([segue.identifier isEqualToString:@"showPhotoList"]) {
PhotoTableViewCell *cell = (PhotoTableViewCell *)[[sender superview]superview];
PhotoListViewController *plvc = segue.destinationViewController;
plvc.model = [_photoLibraryArray objectAtIndex:[_tableView indexPathForCell:cell].row];
}
}