调用didReceiveMemoryWarning时向用户生成警报 [英] Generating alert to User when didReceiveMemoryWarning is called
问题描述
我看到一些应用程序在检测到内存不足时会生成警告。我尝试在我的应用程序中执行此操作但遇到了问题。使用模拟器模拟内存警告,生成的警报会弹出两次,然后我才能点击确定,然后在最后一次消失之前再次弹出9次。
I've seen some apps that generate a warning when low memory is detected. I tried to do this in my app but ran into a problem. Using the simulator to simulate a memory warning, the alert generated pops up twice before I can hit "ok" and pops up 9 more times after that times before it finally goes away.
调用didReceiveMemoryWarning时生成警报是不是一个坏主意?
Is it a bad idea to generate an alert when didReceiveMemoryWarning is called?
如果没有,是否有更好的方法来执行此操作而不是我在下面的内容?
If not, is there a better way to do this than what I have below?
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
...
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Warning"
message:@"Your device is low on memory..."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
谢谢,
phil
推荐答案
一般来说,您不应该通知用户内存不足。毕竟,他们能做什么?您的应用程序是前台应用程序,除了Apple应用程序之外,它正在消耗设备的大部分内存。用户在看到内存消息时要做什么?
Generally speaking, you shouldn't notify a user about low memory. After all, what can they do? Your app is the foreground app, which (aside from the Apple apps) is consuming most of the device's memory. What is the user going to do when they see the memory message?
当您收到内存不足通知时,您应该专注于释放内存,而无需用户交互。
When you get a low memory notification, you should solely focus on freeing memory, without user interaction.
这篇关于调用didReceiveMemoryWarning时向用户生成警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!