【发布时间】:2020-09-20 03:48:56
【问题描述】:
我在这个问题上花了很多时间,所以我找不到任何解决方案。
我使用pushViewController 方法(这里是问题)和菜单(非模态)从我的TopBar 点击头像打开SettingsViewController。
当我点击注销按钮时,我想关闭这个推送的 ViewController。
下面是我在一些 VC 中使用的一个功能,效果很好。
func goToSettingsView() {
let vc = SettingsViewController(nibName: "SettingsViewController", bundle: nil)
vc.modalPresentationStyle = .fullScreen
self.navigationController!.pushViewController(vc, animated: true)
for constraint in vc.view.constraints {
if constraint.identifier == "alignTopHeader" {
constraint.constant = 0
}
}
}
当我单击注销按钮不起作用并且当我从 (LoginViewController) 登录时,此 SettingsViewController 仍然显示,但我会在没有任何模式的情况下进入主屏幕。
我做了一些想法,但还没有很好地工作。
第一个想法是:
下面是我在 SettingsViewController 中的注销 IBaction:
- (void)logout {
[self dismissViewControllerAnimated:YES completion:nil];
[[UserManager shared] logoutUserWithSuccessBlock:^{
[self presentLoginViewController];
}];
}
LoginViewController 已关闭,但 self 是 SettingsViewController 的目标?
第二个想法:
我在 LoginViewController 的 AppDelegate "backToRoot" 中添加了一个声明的函数,并从 viewWillDisappear 调用。
[appDelegate backToRoot];
AppDelegate.m 文件中的函数
-(void)backToRoot {
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
PresentationsPickerViewController *mainvc = [[PresentationsPickerViewController alloc] init];
[self setCenterPanelWithViewController:mainvc];
}
但仍然不能使用模态,当 SettingsViewController 不是模态时它可以正常工作。
您知道如何在注销操作中隐藏/关闭推送的 SettingsViewController 吗?
【问题讨论】:
标签: ios objective-c swift uiviewcontroller