1

I am attempting to make a modal custom transition where I need the frame the first cell of a tableview in the view controller I am transitioning TO. When I put breakpoints in animateTransition:transitionContext after the following code:

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
UITableViewCell *cell = [toViewController.tableView cellForRowAtIndexPath:indexPath];

I see that the tableview is nil, along with all the other controls on the page.

After much searching I was able to find a similar question which suggested using the following code when pushing a vc:

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.02 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [self presentViewController:detailViewController animated:YES completion:nil];
});

But that doesn't work, the tableview and all other page elements are nil in animateTransition:transitionContext

I understand that I am getting nil because at this point in the view lifecycle, tableview has not been calculated yet, but isn't there some way to reference to a tableview cell in a custom transition?

Matt Miller
  • 1,421
  • 1
  • 15
  • 24

1 Answers1

0

The short answer is no. As you said, those things will only be available to you when the transition is complete.

In your second code sample using GCD, that only makes matters worse because all it's doing is deferring execution of the actual transition - which still means all the elements are nil.

Dreaming In Binary
  • 1,197
  • 6
  • 8