与自定义segue崩溃

时间:2013-05-17 12:27:44

标签: ios ipad segue uistoryboardsegue uiviewanimationtransition

我创建了一个自定义segue:

-(void)perform{

UIViewController *destination = [self destinationViewController];
UIViewController *source = [self sourceViewController];

[source.view addSubview:destination.view];

CGRect destionationFrame = destination.view.frame;
CGRect sourceFrame = source.view.frame;
CGSize sourceSize = CGSizeMake(sourceFrame.size.height, sourceFrame.size.width);

destination.view.frame = CGRectMake(sourceSize.width,0,destionationFrame.size.width,destionationFrame.size.height);

[UIView animateWithDuration:0.3
                      delay:0
                    options:UIViewAnimationCurveEaseInOut | UIViewAnimationOptionBeginFromCurrentState
                 animations:^{
                     destination.view.frame = CGRectMake(sourceSize.width-destionationFrame.size.width,0,destionationFrame.size.width,destionationFrame.size.height);
                 } completion:^(BOOL finished) {
                     //[source presentModalViewController:destination animated:NO completion:nil];
                     //[source presentModalViewController:destination animated:NO];
                 }];

}

问题在于,如果动画完成后我什么都不做,触摸目标控制器的任何控件都会导致应用程序崩溃。

如果我创建一个presentModalViewController导致屏幕上的任何对象响应。

有任何帮助吗?感谢

2 个答案:

答案 0 :(得分:1)

既然你这样做了:

[source.view addSubview:destination.view];

首先需要这样做:

[source addChildViewController:destination];

不确定它是否能解决您的问题。

答案 1 :(得分:0)

您正在方法中本地创建destinationViewController,您应该将destinationView Controller(目标)作为类成员,以便它的范围将在那里。