ios6自定义segue和ViewDidAppear

时间:2013-02-23 17:43:20

标签: ios segue viewdidload

这可能是一个显而易见的问题,但我无法弄清楚这个问题的正确解决方案。我有一个自定义segue类,它的工作原理是它成功转换到目标控制器。在目标控制器中,我需要获取一些子视图的位置并保存它们以供以后使用。我在ViewDidAppear中这样做。此代码在使用标准segue时有效,但在使用我的自定义segue时,该位置解析为{0,0}。但是,我能够对子视图做其他事情,比如绘制边框。

目的地视图代码:

-(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;
   }
}

自定义代码:

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

}

0 个答案:

没有答案