0

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];

}
minus
  • 320
  • 1
  • 5
  • 14
  • 1
    why are you adding destinationController.view as the subview of sourceViewController.view? – Rakesh Feb 23 '13 at 17:58
  • Removing that line doesn't change the behaviour. I think this is caused by viewDidAppear being called before the final subview.center positions are set, but I don't know the best way to fix it. – minus Feb 24 '13 at 00:32

0 Answers0