我正在使用以下代码在我的应用中加载视图:
- (void)showPicker {
ImagePickerViewController *imagePickerView = [[ImagePickerViewController alloc] initWithNibName:@"ImagePickerViewController" bundle:nil];
[self.navigationController presentModalViewController:imagePickerView animated:YES];
}
如何通过卷曲/卷曲过渡加载它?
提前致谢,
亚辛
答案 0 :(得分:7)
使用您在那里显示的代码,您可以设置imagePickerView的modalTransitionStyle属性。但是,您的可能值(来自SDK文档):
您的其他选择要求您获得更多的发烧友。假设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;
}
}
答案 1 :(得分: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];
}
答案 2 :(得分: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];
}
];