2017-07-27 107 views
0

在我的繪圖應用程序中,我使用UIImage在其上緩存繪圖。如何解決使用UIGraphicsGetImageFromCurrentImageContext時因內存問題而終止?

下面的代碼行導致內存問題:

UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0); 
self.cacheImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

如何使用UIGraphicsGetImageFromCurrentImageContext不會造成內存泄漏?

任何幫助將不勝感激。提前致謝。

回答

2

使用這可能會對你有所幫助。 它幫助我在我的情況

@autoreleasepool { 
    // Write your code here  
} 
+0

它工作正常,現在 謝謝你這麼多 – Abdelrahman

+0

感謝@Abdelrahman –

相關問題