我看到一些应用程序在检测到内存不足时会生成警告.我尝试在我的应用程序中执行此操作但遇到了问题.使用模拟器模拟内存警告,生成的警报会弹出两次,然后才能点击"确定"并在该时间之后突然再次弹出9次,直到它最终消失.
调用didReceiveMemoryWarning时生成警报是一个坏主意吗?
如果没有,有没有比我下面的更好的方法呢?
- (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];
}
Run Code Online (Sandbox Code Playgroud)
谢谢,
菲尔
在我的应用程序中,用户可以向视图添加任意数量的图像.如果他试图添加更大内存大小的图像,应用程序会收到内存警告.所以我想显示一个警报,在收到内存警告级别= 2后不添加图像.是否可以如果是这样请帮助我.谢谢