English 中文(简体)
iPhone view switching - curl transition
原标题:

I m loading a view in my app with the following code:

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

}

How can I load it with a curl up/curl down transition?

Thanks in advance,

Yassin

最佳回答

Using the code you showed there, you could set the modalTransitionStyle property of imagePickerView. But, your possible values are (from the SDK documentation):

  • UIModalTransitionStyleCoverVertical: When the view controller is presented, its view slides up from the bottom of the screen. On dismissal, the view slides back down. This is the default transition style.
  • UIModalTransitionStyleFlipHorizontal: When the view controller is presented, the current view initiates a horizontal 3D flip from right-to-left, resulting in the revealing of the new view as if it were on the back of the previous view. On dismissal, the flip occurs from left-to-right, returning to the original view.
  • UIModalTransitionStyleCrossDissolve: When the view controller is presented, the current view fades out while the new view fades in at the same time. On dismissal, a similar type of cross-fade is used to return to the original view.

Your other option requires you to get a lot fancier. Let s assume the navigationController is the the root view controller of the application, and it s stored in a property of your application delegate called navigationController. You could implement the following methods:

- (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;
    }
}
问题回答

This is now easily available in OS 3.2 and above; you do it like this: --

// 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];
} 

I love these dormant questions. I had a lot of success doing something like this where you use a view transition animation to show the new view and then presentModalViewController in the completionHandler so that your new view is treated as a modal view.

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




相关问题
images sliding continuously with <table> and jQuery

I m trying to write a little test page that circulates images through a window (see image). I have colored boxes inside a table (gray border), with each box being a element. <table id="boxes" ...

WPF 3d rotation animations

I have a few 3d rectangles on my screen that I want to pivot around the Y axis. I want to press down with the mouse, and rotate the 3d object to a max rotation, but when the user moves their mouse, ...

Disable Windows 7 touch animation in WPF

In Windows 7 when you touch the screen there is a short animation that occurs at the touch point. In my WPF app I want to display my own touch points, without showing the one supplied by Windows. ...

jQuery block moving

I wanna move a div block to the top, so I coded like this: CSS part: .movingPart{ margin-top:80px; } jQuery part: $(document).ready(function() { $( #btn ).click(function() { $( .movingPart )....

Direct 2D gnuplot PNG animation?

Can anyone please confirm that yes/no Gnuplot 4.5 (on CVS) can output 2D animated PNG files? I have numerous datasets but one line that I d like to show iteratively in 3 different places in my graph. ...

Visual State Manager VS Animations in WPF

There is a lot of talk about the simplicity of Visual States and the transitions between them in WPF/Silverlight. I have the need to generate animations dynamically at runtime, to animate the ...

Create a ImageIcon that is the mirror of another one

I ll like to know if there is a way to create a ImageIcon that is the mirror of another ImageIcon. Searching on Google, I found how to do it by using many AWT libraries. Is there a way to do it with ...

how to drag in the animation in iphone application?

Iphone application is using the static co-ordinates to reach at some points in the application,which is based on the button event. But what i want is when i drag the item than it should reach at some ...

热门标签