嗨,我有两个 Viewcontroller 一个 和 乙我正在介绍乙来自 的 Controller 一个 Controller 与 当前上下文 我在下面粘贴了我的编码。我想从 推送乙 Controller 到 中号 Controller ,我知道当我们展示时没有分配导航 Controller ,如果我展示带有 rootviewcontroller 的导航 Controller ,我无法获得透明的结果。
UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
ChooseAddressVc *sec=[story instantiateViewControllerWithIdentifier:@"ChooseAddressVc"];
sec.myDelegate = self;
sec.modalPresentationStyle = UIModalPresentationOverCurrentContext;
sec.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:sec animated:YES completion:^{
}];
从 View Controller B 推送到 C
UIStoryboard*Story=[UIStoryboard storyboardWithName:@"Main2" bundle:nil];
AddNewAddressVc*choose=[Story instantiateViewControllerWithIdentifier:@"AddNewAddressVc"];
[self.navigationController pushViewController:choose animated:YES];
注意:当我呈现当前上下文时,我需要从 B Controller 推送到 C Controller 。 为了更好地理解 : 当我们需要获得透明效果时,我们无法将导航 Controller 分配为 Root View Controller
最佳答案
在你的情况下self.navigationController
在 B View Controller 中为零。您需要创建 UINavigationController
B View Controller 为 rootViewController
.礼物创建UINavigationController
从 A 而不是呈现 B View Controller ,之后您可以使用 self.navigationController
在 B View Controller 中。
您的代码已编辑:
UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
ChooseAddressVc *sec=[story instantiateViewControllerWithIdentifier:@"ChooseAddressVc"];
sec.myDelegate = self;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:sec];
navController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
navController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:navController animated:YES completion:^{
}];
关于ios - 从当前上下文推送导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43498030/