故事板视图控制器之间的翻转过渡不起作用
问题描述:
我在设置故事板之间的翻转过渡时遇到了很多麻烦。下面的方法被调用时,该应用程序崩溃。我收到错误消息:故事板视图控制器之间的翻转过渡不起作用
[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];
}
我会很感激任何帮助。
答
由于您正在使用故事板。这是更准确的,试试这个:
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"firstStoryVC"];
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:vc animated:YES completion:NULL];
但一定要命名视图的identifier
“firstStoryVC”否则就会崩溃,无法正常工作。
然后,当你想dimiss的观点:
[self dismissModalViewControllerAnimated:YES];
答
试试这个,它会给你完全控制时间和动画。
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];