如何更改modalTransitionStyle?

时间:2010-08-25 04:34:44

标签: objective-c cocoa-touch

我目前正在使用此代码打开信息窗口

-(IBAction)showInfo:(id)sender { InfoView *info = [[InfoView alloc] initWithNibName:nil bundle:[NSBundle mainBundle]]; [self presentModalViewController:info animated:YES]; [info release]; }

它目前使用默认的过渡样式UIModalTransitionStyleCoverVertical,我想让它使用不同的过渡样式,例如UIModalTransitionStyleFlipHorizo​​ntal,我该怎么做?

2 个答案:

答案 0 :(得分:5)

来自apple文档 http://developer.apple.com/iphone/library/samplecode/AddMusic/Listings/Classes_MainViewController_m.html#//apple_ref/doc/uid/DTS40008845-Classes_MainViewController_m-DontLinkElementID_6

MusicTableViewController *controller = [[MusicTableViewController alloc] initWithNibName: @"MusicTableView" bundle: nil];
controller.delegate = self;

controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

[self presentModalViewController: controller animated: YES];
[controller release];

答案 1 :(得分:1)

- (IBAction)next {
page2 *page2_xib = [[page2 alloc] init];
page2_xib.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
//page2_xib.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
//page2_xib.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
//page2_xib.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:page2_xib animated:YES];
}