我正在使用 Storyboard构建我的应用程序。因此我可以在按下按钮时通过拖动打开另一个 View Controller 。然后我可以选择 presentation
= over current context
对于 Storyboard中的 segue。但我想要以编程方式执行此操作。我找到了一个答案,但它说它只适用于 ipad。我正在构建一个通用应用程序,所以我想在所有设备上使用它。
- 这可能吗。
- 我该怎么做。
在我的第一个 View Controller 中
UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
UIViewController *middleViewController = [story instantiateViewControllerWithIdentifier:@"FlightMiddleViewController"];
在我的第二个 View Controller 中,我放置了 viewDidLoad 方法
self.modalPresentationStyle = UIModalPresentationOverCurrentContext;
它工作了一段时间。这意味着它透明了一段时间,然后屏幕变黑了。我不知道为什么会这样。
最佳答案
它也适用于 ios 9 的 iphone >=
这就是你想要做的。
在你的第一个 View Controller 中,在你设置应该呈现哪个 View 之前,
- (IBAction)searchNowAction:(id)sender {
UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
UIViewController *secondViewController = [story instantiateViewControllerWithIdentifier:@"secondviewControllerSBname"];
secondViewController.modalPresentationStyle = UIModalPresentationOverFullScreen;
secondViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:secondViewController animated:YES completion:nil];
}
这也适用于 iPhone。
关于ios - 如何以编程方式导航到另一个 View Controller ,在 ios 9 中使用 "over current context "表示, Objective-C ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35053143/