This might be an obvious question, but I cannot figure out the correct solution to this problem. I have a custom segue class, which works in that it successfully transitions to the destination controller. In the destination controller, I need to get the position of some subviews and save them for later use. I am doing this in ViewDidAppear. This code works when using a standard segue, but the position resolves to {0, 0} when using my custom segue. I am, however, able to do other things to the subview, like draw a border.
Code for destination view:
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
for (UIView * view in self.videos) {
[self.origCenter setObject:[NSValue valueWithCGPoint:[view.superview convertPoint:view.center toView:view.superview]]
forKey:[NSValue valueWithNonretainedObject:view]];
view.layer.borderColor = [UIColor redColor].CGColor;
view.layer.borderWidth = 3.0f;
}
}
Code for custom segue:
-(void)perform {
UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationController = (UIViewController*)[self destinationViewController];
[sourceViewController.view addSubview:destinationController.view];
CATransition* transition = [CATransition animation];
transition.duration = .25;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[sourceViewController.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[[self sourceViewController] presentModalViewController:[self destinationViewController] animated:NO];
}