garethdn
garethdn

Reputation: 12373

App crashes when pushing view controller

I have a view controller which plays a video in viewDidLoad. I have an observer that checks to see when the video is finished and when it detects that the video is finished a method is called which pushes a view controller on to the stack. When this method is called, however, a get the following error in the console:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSPathStore2 setView:]: unrecognized selector sent to instance 0xc6ef8e0'

The code i use is shown below:

....
....
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(advanceToNextView) name:MPMoviePlayerPlaybackDidFinishNotification object:player];  
....
....
- (void) advanceToNextView {

    UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"spoonVC"];


    [self.navigationController pushViewController:controller animated:NO];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO];
    [UIView commitAnimations];

}

I don't know what i'm doing wrong. I have checked and double-checked the storyboard identifier is correct.

Upvotes: 2

Views: 659

Answers (2)

Vishal
Vishal

Reputation: 8256

Replace your this code:

[self.navigationController pushViewController:controller animated:NO];

BY:

 [self.navigationController pushViewController:controller animated:YES];

Upvotes: 3

garethdn
garethdn

Reputation: 12373

It found a solution. The way to produce transition animations doesn't seem to be consistent but the following seems to work well for me.

UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"page2"];
    [UIView beginAnimations:@"Flip transition" context:nil];
    [UIView setAnimationDuration:0.80];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationTransition:
     UIViewAnimationTransitionCurlDown
                           forView:self.navigationController.view cache:NO];
    [self.navigationController pushViewController:controller animated:YES];
    [UIView commitAnimations];

Upvotes: 0

Related Questions