2009-12-13 102 views
1

我加载在我的应用程序下面的代码视图:iPhone视图切换 - 卷曲转变

- (void)showPicker { 
ImagePickerViewController *imagePickerView = [[ImagePickerViewController alloc] initWithNibName:@"ImagePickerViewController" bundle:nil]; 
[self.navigationController presentModalViewController:imagePickerView animated:YES]; 

}

我怎么能与一个向上卷曲/向下卷曲过渡加载它?

由于提前,

亚辛

+0

我不认为你可以,因为你提出了一个模态视图控制器,你不会切换视图,但控制器。我刚刚用基本的UIView动画和'animated'参数设置为'NO'对其进行了测试,但没有正常工作。 – Joost 2009-12-13 11:41:23

+0

JoostK,你应该把它放在答案中,以便系统可以处理它。现在,如果您的答案正确,亚辛无法将问题标记为已回答。 – TechZen 2009-12-13 16:13:46

回答

7

使用你表明那里的代码,你可以设置imagePickerView的modalTransitionStyle财产。但是,你可能值是(来自SDK文档):

  • UIModalTransitionStyleCoverVertical:当呈现视图控制器,其观点从屏幕底部向上滑动。解雇后,视线滑落。这是默认的转换样式。
  • UIModalTransitionStyleFlipHorizo​​ntal:当呈现视图控制器时,当前视图从右到左启动水平3D翻转,导致新视图的揭示就像它在前一个视图的背面一样。在解雇时,翻转从左到右发生,返回到原始视图。
  • UIModalTransitionStyleCrossDissolve:显示视图控制器时,当新视图同时淡入时当前视图淡出。解雇后,使用类似的淡入淡出模式返回原始视图。

你的其他选择需要你有更多的发烧友。我们假设navigationController是应用程序的根视图控制器,它存储在您的应用程序委托的名为navigationController的属性中。您可以执行以下方法:

- (void)curlInViewController:(UIViewController *)viewController { 
    self.curledViewController = viewController; 

    [UIView beginAnimations:@"curlInView" context:nil]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.window cache:YES]; 
    [self.navigationViewController.view removeFromSuperview]; 
    [self.window addSubview:viewController.view]; 
    [UIView commitAnimations]; 
} 

- (void)curlOutViewController { 
    [UIView beginAnimations:@"curlOutView" context:nil]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:) 
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.window cache:YES]; 
    [self.curledViewController removeFromSuperview]; 
    [self.window addSubview:navigationController.view]; 
    [UIView commitAnimations]; 
} 

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { 
    if([animationID isEqualToString:@"curlOutView"]) { 
     self.curlViewController = nil; 
    } 
} 
+0

太好了,非常感谢。我现在正在使用modalTransitionStyle属性,明天我要实现上面发布的方法。 – iYassin 2009-12-15 20:35:57

4

这现在可以轻松地在OS 3.2及更高版本中使用;你这样做: -

// if the legend button is tapped, curl up the map view to display the legend view underneath. 
- (IBAction) legendButtonPressed:(id) sender 
{ 
    UIViewController *legend = [[LegendViewController alloc] init]; 
    legend.modalTransitionStyle = UIModalTransitionStylePartialCurl; 
    legend.modalPresentationStyle = UIModalPresentationFullScreen; 
    [self presentModalViewController:legend animated:YES]; 
    [legend release]; 
} 
+0

非常好让我更好地格式化它 – 2011-04-19 04:21:22

1

我喜欢这些休眠问题。我有很多成功的做法,例如使用视图过渡动画显示新视图,然后在completionHandler中呈现ModalViewController,以便将新视图视为模态视图。

UIView *container = self.view.window; 
    [self.theNewViewController viewWillAppear:YES]; 
    [UIView transitionWithView:container 
        duration:kAnimationViewTransition 
        options:UIViewAnimationOptionTransitionCurlUp 
       animations:^{ 
        [self.navigationController.view removeFromSuperview]; 
        [container addSubview: self.theNewViewController.view]; 
       } 
       completion:^(BOOL finished) { 
        [self presentModalViewController:self.theNewViewController animated:NO]; 
       } 
];