1

我正在使用以下代码在我的应用程序中加载视图:

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

}

如何通过卷曲/卷曲过渡加载它?

提前致谢,

亚辛

4

3 回答 3

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;
    }
}
于 2009-12-14T00:14:53.433 回答
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];
} 
于 2010-08-06T16:32:04.547 回答
1

我喜欢这些潜伏的问题。我在做类似这样的事情时取得了很大的成功,您使用视图转换动画来显示新视图,然后在 completionHandler 中使用 presentModalViewController,以便您的新视图被视为模态视图。

    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];
                }
 ];
于 2012-04-24T21:56:58.970 回答