iPhone is there a way to set the type of animation when going from one view to another?
I'm using presentModalViewController to go from view controller to view controller.开发者_Go百科 Right now the animations are up and down when it goes from one view to another. Can I change it to right and left? I did not see any settings for this in the method presentModalViewController Ted
Try this before presenting the modal vc:
[sampleViewController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
// or..
// [sampleViewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
// or..
// [sampleViewController setModalTransitionStyle:UIModalTransitionStylePartialCurl];
See the modalTransitionStyle
Property of a UIViewController - Here are the Reference docs
You can make convenience methods for all styles like so (from Modal View Controller Example):
- (IBAction)showDefault:(id)sender {
SampleViewController *sampleView = [[[SampleViewController alloc] init] autorelease];
[self presentModalViewController:sampleView animated:YES];
}
- (IBAction)showFlip:(id)sender {
SampleViewController *sampleView = [[[SampleViewController alloc] init] autorelease];
[sampleView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:sampleView animated:YES];
}
- (IBAction)showDissolve:(id)sender {
SampleViewController *sampleView = [[[SampleViewController alloc] init] autorelease];
[sampleView setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentModalViewController:sampleView animated:YES];
}
- (IBAction)showCurl:(id)sender {
SampleViewController *sampleView = [[[SampleViewController alloc] init] autorelease];
[sampleView setModalTransitionStyle:UIModalTransitionStylePartialCurl];
[self presentModalViewController:sampleView animated:YES];
}
精彩评论