ios - 自定义转场崩溃

标签 ios ipad segue uistoryboardsegue uiviewanimationtransition

我创建了一个自定义转场:

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

}

问题是,如果我在动画完成时不执行任何操作,触摸目标 Controller 的任何控件都会导致应用程序崩溃。

如果我制作一个presentModalViewController,则会导致屏幕上的任何对象做出响应。

有什么帮助吗?谢谢

最佳答案

既然你这样做了:

[source.view addSubview:destination.view];

您首先需要执行以下操作:

[源addChildViewController:目标];

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

关于ios - 自定义转场崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16609050/

相关文章:

ios - subview (UILabel)放置在 super View (UITextView)中时不遵守约束

iphone - UIAlertView 中 UIView 中的 UITextField 不起作用?

swift - iOS Swift - 将数据从第一个 ViewController 传递到第三个 ViewConTroller

xcode - 一段时间后更改 Xcode View

ios - 运行 7.0.4 的 iPad 出现半透明问题

ios - iOS8 中的扩展 - 由于没有系统应用程序而终止

iphone - 当 View Controller 弹出时,MKMapView 使应用程序崩溃

ios - UISwitch:使触摸区域大于默认触摸区域

iOS:如何在 iPad 上更改 MPMoviePlayerViewController 的方向?

ios - UINavigationController 在 iOS 7 上像模式一样推送