当我将父 UINavigationController
的 modalPresentationStyle
设置为 UIModalPresentationCurrentContext
来呈现我的 UIViewController
时,UIViewController
没有滑入。没有使用过渡。
这是我的代码:
UIViewController *viewController = [[UIViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
navController.navigationBarHidden = YES;
self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:navController animated:YES completion:nil];
当我不设置 modalPresenttionStyle
时,一切正常。但我需要这种样式,因为我希望 UIViewController
呈现为覆盖层。
顺便说一句:当 ViewController
被关闭时,动画效果很好。
最佳答案
根据 UIViewController.h
header 定义:-
/*
定义以模态方式呈现时将用于此 View Controller 的过渡样式。放
要呈现的 View Controller 上的此属性,而不是演示者。默认为
UIModalTransitionStyleCoverVertical
。
*/
所以你应该像这样在 presentingViewController
上应用它:-
UIViewController *viewController = [[UIViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
navController.navigationBarHidden = YES;
//Here is the change
navController.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:navController animated:YES completion:nil];
关于iphone - 当 modalPresentationStyle 设置为 UIModalPresentationCurrentContext 时没有动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14922539/