0
我有一個帶有課程的表格視圖,想要在詳細視圖控制器中傳遞課程名稱。但它總是通過第一行。prepareForSegue沒有在表格中傳遞適當的行查看
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewRowAction *edit = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"edit" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self performSegueWithIdentifier:@"editLesson" sender:nil];
}];
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"editLesson"]) {
NSManagedObject *selectedLesson = [self.lessons objectAtIndex:[[self.tableView indexPathForSelectedRow] row]];
EditLessonViewController *destViewController = segue.destinationViewController;
destViewController.lesson = selectedLesson;
}
}
我只是想說使用iVars,但這是整潔。你不能依賴table.indexPathForSelectedRow來獲取正在編輯的行。 – 2015-02-10 16:17:06
幫助,非常感謝! – ermolushka 2015-02-10 16:40:41