您的位置:首页 > 其它

iphone模拟器上模拟内存警告

2011-06-17 10:27 295 查看
有三种方法可以实现内存警告。

 

1.模拟器菜单:Hardware-》Simulate Memory Warning

 

2.用程序的方法实现,只需要一句代码:

CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), (CFStringRef)@"UISimulatedMemoryWarningNotification", NULL, NULL, true);
 

 

3.这是私有api方法:

SEL memoryWarningSel = @selector(_performMemoryWarning);
if ([[UIApplication sharedApplication] respondsToSelector:memoryWarningSel]) {
[[UIApplication sharedApplication] performSelector:memoryWarningSel];
}else {
NSLog(@"%@",@"Whoops UIApplication no loger responds to -_performMemoryWarning");
}
 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  iphone null api