iOS ARC(?) 偷走了我的搜索栏

发布于 2024-12-27 15:33:58 字数 902 浏览 5 评论 0原文

我制作了一个与 Apple 的联系人应用程序非常相似的 iOS5 应用程序。一个搜索栏,一个搜索显示控制器和一个表格视图。当用户点击单元格时,会使用 segues 呈现详细视图(模态样式...)。一切都运行良好,但是...我见过我的应用程序在真正的 iPhone 4S 设备上崩溃,当时该应用程序在后台休眠了几个小时,然后再次激活。在有序情况下不可能重新创建崩溃。好的,某种内存问题...

在 iOS 模拟器上,如果

->点击单元格(或设置视图的按钮) ->显示详细视图(或显示设置视图) ->发出“模拟内存警告” ->用户尝试使用“完成”按钮返回。

- (IBAction)done:(id)sender
{
    [self.delegate detailedViewControllerDidFinish:self];
}

- (void)detailedViewControllerDidFinish:(DetailedViewController *)controller
{    
    [self dismissModalViewControllerAnimated:YES];
}

2012-01-17 19:58:43.777 MyApp[89968:f803] * 由于以下原因终止应用程序 未捕获异常'NSUnknownKeyException',原因:'[ setValue:forUndefinedKey:]: 这个类不是键值 关键搜索栏的编码兼容。 *第一次抛出调用堆栈:...

因此,由于某种原因,当操作系统想要回我的应用程序的一些内存时,serachbardisplaycontrol 会变得无效(我猜)

有什么想法吗?

I've made a iOS5-app quite similar to Apple's Contacts-app. A searchbar, a serachdisplaycontroller a tableview. When the user tap a cell a detailed view is presented (modal-style...) using segues. Everything works well, but... I've seen my app crash on the real iPhone 4S device when the app has been sleeping in the background for several hours and then get active again. The crash is impossible to re-create under ordered circumstances. Ok, some kind of memory issue...

On the iOS-simulator I can see the crash if

-> A cell is tapped (or a button for the settings-view)
-> The detailed view is presented (or the settings-view is presented)
-> A "Simulate Memory Warning" is issued
-> The user try to navigate back using a "Done"-button.

- (IBAction)done:(id)sender
{
    [self.delegate detailedViewControllerDidFinish:self];
}

- (void)detailedViewControllerDidFinish:(DetailedViewController *)controller
{    
    [self dismissModalViewControllerAnimated:YES];
}

2012-01-17 19:58:43.777 MyApp[89968:f803] * Terminating app due to
uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value
coding-compliant for the key searchBar.'
*
First throw call stack:...

So for some reason the serachbardisplaycontrol get invalid (I guess) when the OS want some of my app's memory back

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你怎么这么可爱啊 2025-01-03 15:33:58

我想我已经成功解决了这个问题。这归结为当触发低内存条件时搜索栏处于活动状态。当您遇到内存不足的情况时,请执行以下操作:

[self.searchDisplayController setActive:NO animated:NO];

这应该可以修复它。

I think I have successfully solved this one. It comes down to the search bar being active when a low-memory condition is triggered. When you hit a low-memory condition, do this:

[self.searchDisplayController setActive:NO animated:NO];

That should fix it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文