2015-10-15 57 views
0

我已經實現GPUImage庫中現有的視頻應用過濾器,現在的問題是,應用程序是崩潰時,我鎖定裝置,我還設置BOOL變量獲得應用程序的當前狀態,之後應用程序崩潰包子不幸resignActive電話。崩潰發生在這行代碼中。如何在後臺管理GPUImage movieFile處理?

[self.context presentRenderbuffer:GL_RENDERBUFFER]; 

您能否給我建議什麼是解決這個問題的最佳方法。

回答

0
-(void)viewWillAppear:(BOOL)animated{ 
    [[NSNotificationCenter defaultCenter]addObserver:self 
              selector:@selector(EnterBackground:) 
               name:UIApplicationWillResignActiveNotification 
               object:nil]; 

    [[NSNotificationCenter defaultCenter]addObserver:self 
              selector:@selector(DidBecomeActive:) 
               name:UIApplicationDidBecomeActiveNotification 
               object:nil]; 

} 
- (void)EnterBackground:(NSNotification*)notification{ 
    NSLog(@"Enter in background"); 
     [self.movieFile endProcessing]; 
     [self.filter removeAllTargets]; 
     [self.movieFile removeAllTargets]; 
} 

- (void)DidBecomeActive:(NSNotification*)notification{ 
    [_movieFile startProcessing]; 
} 

不要忘了在viewWillDisappear

刪除觀察員