gpt4 book ai didi

ios - iOS7 中的 ModalView 崩溃

转载 作者:行者123 更新时间:2023-11-29 03:24:06 24 4
gpt4 key购买 nike

我在 iOS7 中遇到应用程序崩溃问题,但在 iOS6 上却可以正常工作。在从我的 AppDelegate 调试下一个代码时,我检查了在 iOS7 中是否执行了下一个函数,然后加载了模态视图 Controller 。

- (void)presentModalWebViewWithURL:(NSURL *)url title:(NSString *)title
{
[self.modalWebViewController dismissModalViewControllerAnimated:YES];
self.modalWebViewController = [[[MyModalWebViewController alloc] initWithURL:url] autorelease];
self.modalWebViewController.title = title;
UINavigationController *nav = [self.modalWebViewController modalNavigationControllerWithTarget:self dismissSelector:@selector(dismissModalWebView)];
[self.window.rootViewController presentViewController:nav animated:YES completion:NULL];
}

在 iOS6 中,我检查了函数在最后一行停止执行,直到加载模态视图 Controller 。

在 iOS7 中发生的事情是,当模态视图 Controller 尝试加载正在运行的 viewWillAppear 时,我能够检查模态视图 Controller 是否已更改所有值,甚至属性都指向对象不同类型的。我猜它们正在被释放,但我不知道为什么以及如何解决它。有什么建议吗?

最佳答案

当您关闭模态视图 Controller 时,您应该在呈现该 View Controller 的 View Controller 上调用关闭方法。此外,dismissModalViewControllerAnimated: 方法已被弃用,您应该使用 dismissViewControllerAnimated:completion:。因此,查看您的代码,您可能应该在 self.window.rootViewController 上调用解雇方法,因为这就是您呈现模态视图的方式。

另外,不知道代码的其余部分看起来如何,我假设第一次调用时,self.modalWebViewController 为 nil,所以您可能想检查 self 是否.modalWebViewController 在您调用关闭之前设置为某些内容,并且在您关闭它时将其设置为 nil。

关于ios - iOS7 中的 ModalView 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20706581/

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