故事板视图控制器之间的翻转转换不起作用

时间:2012-07-08 18:54:54

标签: objective-c ios

我在故事板之间设置翻转过程时遇到了很多麻烦。调用以下方法时,应用程序崩溃。我收到错误消息:

[NSPathStore2 setView:]: unrecognized selector sent to instance...

这是我的代码:

- (void)advanceToNextViewController {

    humptyDumptyViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"firstStoryVC"];
     /*
    [self.navigationController pushViewController:controller animated:YES];
    */
    [UIView beginAnimations:@"animation" context:nil];
    [self.navigationController pushViewController:controller animated:NO]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO]; 
    [UIView commitAnimations];


}

我很感激任何帮助。

2 个答案:

答案 0 :(得分:3)

因为您正在使用故事板。这更准确,试试这个:

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"firstStoryVC"];
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:vc animated:YES completion:NULL];

但请务必将您的观点命名为identifier firstStoryVC ”,否则会崩溃并无法正常工作。

然后当你想要诋毁视图时:

[self dismissModalViewControllerAnimated:YES];

答案 1 :(得分:2)

试试这个,它会让你完全控制时间和动画。

humptyDumptyViewController *controller = [self.storyboardinstantiateViewControllerWithIdentifier:@"firstStoryVC"];
[UIView  beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController:controller animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
相关问题