推送视图控制器时应用程序崩溃

时间:2012-09-08 18:35:12

标签: iphone objective-c ios ipad automatic-ref-counting

我有一个视频控制器,可以在viewDidLoad中播放视频。我有一个观察者检查视频何时完成以及何时检测到视频已完成,调用方法将视图控制器推送到堆栈。但是,调用此方法时,在控制台中会出现以下错误:

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

我使用的代码如下所示:

....
....
[[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];

}

我不知道我做错了什么。我已经检查并仔细检查了故事板标识符是否正确。

2 个答案:

答案 0 :(得分:3)

替换此代码:

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

BY:

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

答案 1 :(得分:0)

它找到了解决方案。制作过渡动画的方式似乎并不一致,但以下似乎对我有用。

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