gpt4 book ai didi

iphone - dismissViewControllerAnimated 无法使用快速对话框工作

转载 作者:行者123 更新时间:2023-11-28 22:40:56 25 4
gpt4 key购买 nike

我正在使用 QuickDialog 推送登录表单。除了无法关闭 View Controller 外,一切正常。代码如下:

- (void)onLogin:(QButtonElement *)buttonElement
{
[self loading:YES];
Info *info = [[Info alloc] init];
[self.root fetchValueUsingBindingsIntoObject:info];
[self.client loginWithUsername:info.login password:info.password onSuccess:^(NSDictionary *result) {
NSLog(@"user signed in");
[self loading:NO];
[self dismissViewControllerAnimated:YES completion:nil];
} onFailure:^(NSError *error) {
NSLog(@"login error");
}];
}

我正在使用这些代码来推送这个 View Controller

QRootElement *root = [[QRootElement alloc] initWithJSONFile:@"loginform"];
LoginController *loginController = (LoginController *)[QuickDialogController controllerForRoot:root];
[self.navigationController pushViewController:loginController animated:YES];

最佳答案

我很想告诉你这样做:

[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];

这是 Apple 的文档:

The presenting view controller is responsible for dismissing the view controller it presented. If you call this method on the presented view controller itself, however, it automatically forwards the message to the presenting view controller.

我不确定为什么您的电话没有“转接”和关闭。也许您使用 presentModalViewController 进行了展示?如果是这种情况,请使用 dismissModalViewControllerAnimated 进行平衡,这可能会解决。

当然,我们都假设您的其余代码是正确的,并且您实际上看到 NSLog(@"user signed in"); 在您登录时打印。

祝你好运!

>> 更新<<

哇,对不起。我刚刚注意到您写了“QuickDialog to push a login form”,并看到您添加了一个示例来说明如何显示此屏幕。由于您将其推送到导航 Controller 堆栈,因此需要将其弹出。这将解决问题:

[self.navigationController popViewControllerAnimated:YES];

享受吧。

关于iphone - dismissViewControllerAnimated 无法使用快速对话框工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14537730/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com