Fran Fox
Fran Fox

Reputation: 575

Crash with custom segue

I create a custom 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];
                 }];

}

The problem is that, if i do nothing when the animation is finished, touching any controls of destination controller causes app crash.

If i make a presentModalViewController causes that any object on the screen responds.

Any help? Thanks

Upvotes: 0

Views: 362

Answers (2)

Mike Pollard
Mike Pollard

Reputation: 10195

Since you're doing this:

[source.view addSubview:destination.view];

You first need to do this:

[source addChildViewController:destination];

Not sure if it will resolve your issues though.

Upvotes: 1

Amit
Amit

Reputation: 1043

You are creating the destinationViewController locally in the method, You should make the destinationView Controller (destination) as a class member so that it's scope will be there.

Upvotes: 0

Related Questions