【发布时间】:2016-11-20 01:41:11
【问题描述】:
我正在使用 MZFormSheetPresentationController 显示一个对话框,要求用户输入密码,如下图所示: 用户点击OK后会出现另一个视图控制器,如下图所示: 但是在关闭新的视图控制器后,旧的视图控制器仍然存在在我的情况下应用这样的答案我的代码我正在使用什么:
- (IBAction)okButtonTouchDown:(id)sender {
// UIStoryboard *storyboard = self.storyboard;
// UINavigationController *nav = [storyboard instantiateViewControllerWithIdentifier:@"myprofile"];
// [self presentViewController:nav animated:YES completion:^{
// [self dismissViewControllerAnimated:YES completion:nil]; // here the self point to the new view controller not to the old one //
//[self dismissViewControllerAnimated:YES completion:^{
// UINavigationController *nav = [storyboard instantiateViewControllerWithIdentifier:@"myprofile"];
// [self presentViewController:nav animated:YES completion:^{
//}];
// }];
//}];
__weak EditProfileViewController *aBlockSelf = self;
UIStoryboard *storyboard = self.storyboard;
UINavigationController *nav = [storyboard instantiateViewControllerWithIdentifier:@"myprofile"];
[self presentViewController:nav animated:YES completion:^{
[[aBlockSelf presentingViewController] dismissViewControllerAnimated:YES completion:nil];
}];
}
// i try this solution but the new view controller presented and after some time dismissed //
即使我尝试在完成后关闭viewcontroller,我也会遇到此错误警告:尝试在其视图上显示不在窗口层次结构中的视图!
那么有没有办法不使用委托和协议方法来解决这个问题?
【问题讨论】:
-
你应该先解散,然后再展示新的 VC
-
@shubhank 我已经这样做了,但我遇到了不在窗口层次结构中!错误信息
-
好吧,自从 VC 被解散后,你的内部块将有 self nil。所以你需要在这里使用委托并将VC呈现在父级中。也无需在 cmets 中大喊大叫!
-
你能有一个简单的教程如何使用委托协议,因为我找不到一些简单的
-
理想情况下,您应该关闭 sheetPresentation 视图,然后只有您应该加载新视图....这是根据视图层次结构执行的确切方法...
标签: ios objective-c iphone