OGeek|极客世界-中国程序员成长平台

标题: ios - 如何在 ios 中关闭 View Controller ? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 15:40
标题: ios - 如何在 ios 中关闭 View Controller ?

我创建了一个库,如果主应用程序调用我的库,它会显示它,并从服务器下载一些数据。但是如果服务器有一些错误我想杀死库 View ,但它不起作用 我在主机应用中有一个委托(delegate):

-(void)libraryResultNSString*)result{
NSLog(@"result: %@", result);
}

我在 viewWillAppear 方法中从服务器下载数据,下载有一个这样的委托(delegate)方法:

-(void)networkManagerErrorNSString *)error{
[hud hide:YES];
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
[self.delegate libraryResult:error];
}

我在日志中看到,应用程序返回到主应用程序,但 View 没有改变。 如何解决这个问题?我的代码有什么问题?



Best Answer-推荐答案


改变这一行

[self.presentedViewControllerdismissViewControllerAnimated:YES 完成:nil];

[self dismissViewControllerAnimated:YES completion:nil];

关于ios - 如何在 ios 中关闭 View Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31108923/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4