![](/img/trans.png)
[英]Weird three20 graphics bug in thumb viewer when running in release mode
[英]Release graphics when app entered to background mode
在Apple文檔中,您可以發現Apple建議在應用程序進入后台模式時釋放大量數據,如圖像。
如何從UIViews
和其他數據中釋放圖像?
如何釋放從圖像UIViews
所有viewController
正確的方式?
如何在app獲取applicationWillResignActive
消息時恢復數據?
如果有人有一個很好的例子或鏈接,請顯示它。
添加到app delegate 2方法
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_APP_BACKGROUND object:nil];
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_APP_BACKGROUND object:nil];
}
使用方法創建BaseViewController:
- (id)init
{
self = [super init];
if (self) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillForeground) name:NOTIFICATION_APP_FOREGROUND object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidBackground) name:NOTIFICATION_APP_BACKGROUND object:nil];
}
return self;
}
- (void)appDidBackground {
}
- (void)appWillForeground {
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
從BaseViewController子類化所有視圖控制器。 在方法appDidBackground中,您應該在appWillForeground中釋放不需要的數據 - 恢復它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.