В приложении iOS, почему makeForSegue возникает до didSelectRowAtIndexPath
Я пытаюсь изменить поведение ячейки: 1) Когда Cell Tapped, отметьте ячейку как заполненную галочкой 2) Когда нажата кнопка "Сведения о раскрытии детали", выполните "Сессия". 3) В tableView: didSelectRowAtIndexPath: У меня:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
AWDelivery *delivery = [self.fetchedResultsController objectAtIndexPath:indexPath];
[delivery toggleDelivered: delivery];
[self configureCheckmarkForCell:cell withDelivery:delivery];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (debugging) NSLog(@"[%s] [%d]", __PRETTY_FUNCTION__, __LINE__);
}
deselectRowAtIndexPath должен обходить segue, но это не так.
NSLogs: a) в 2012-04-29 18: 50: 00.848 Доставка [3148: fb03] [- [DeliveryTVC prepareForSegue: отправитель:]] [168] b) в 2012-04-29 18: 50: 01.245 Поставка [3148: fb03] [- [Таблица TVTVTVTV: didSelectRowAtIndexPath:]] [93]
Заметьте, что 'didSelect' происходит после 'prepareForSegue'.
Любые подсказки будут наиболее оценены.
Ответы
Ответ 1
Есть ли у вас привязка к ячейке таблицы? Вместо этого попробуйте перетащить его между двумя контроллерами представления (та, которая содержит таблицу и ту, где вы хотите, чтобы она была).
Затем выполните его вручную ([self performSegueWithIdentifier:@"MySegue"];
), когда tableView:accessoryButtonTappedForRowWithIndexPath:
.
Ответ 2
Если вам нужно получить текущий выбор таблицы в prepareForSegue, вы можете получить его, обратившись к UITableViewController tableView ivar;
[self tableView] indexPathForSelectedRow]
Ответ 3
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure your segue name in storyboard is the same as this line
if ([[segue identifier] isEqualToString:@"ClaimDetailsSeque"])
{
DLog(@"destinationViewController %@",[[segue destinationViewController] topViewController]);
//This syntax is needed when the seque is going through a Navagation Controller
ClaimDetailsFormViewController* vc = (ClaimDetailsFormViewController*)[[segue destinationViewController] topViewController];
//This the the way to get the object from the selected row via the FetchedResultsController
//this is needed because prepareForSegue is called before didSelectRowAtIndexPath
NSIndexPath *selectedIndexPath = [self->claimTableView indexPathForSelectedRow];
ClaimHistory *object = [[self claimHistoryFetchedResultsController] objectAtIndexPath:selectedIndexPath];
MyClaimHistorySM *myCH = [MyClaimHistorySM new];
myCH.policyNumber = object.policyNumber;
myCH.policyStatus = object.policyStatus;
myCH.claimNumber = object.claimNumber;
myCH.insuredName = object.insuredName;
myCH.lossDescription = object.lossDescription;
myCH.dateOfLoss = object.dateOfLoss;
myCH.incidentCloseDt = object.incidentCloseDt;
vc.claimHistorySM = myCH;
}
}
![Seque on Storyboard]()