2012-07-08 55 views
1

我在設置故事板之間的翻轉過渡時遇到了很多麻煩。下面的方法被調用時,該應用程序崩潰。我收到錯誤消息:故事板視圖控制器之間的翻轉過渡不起作用

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


} 

我會很感激任何幫助。

回答

3

由於您正在使用故事板。這是更準確的,試試這個:

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

但一定要命名視圖的identifierfirstStoryVC」否則就會崩潰,無法正常工作。

然後,當你想dimiss的觀點:

[self dismissModalViewControllerAnimated:YES]; 
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]; 
相關問題