2013-04-12 1 views
0

보안상의 이유로 백그라운드로 이동하기 전과 포 그라운드로 이동하기 전에 앱 상태를 제거해야합니다. applicationWillResignActive의 코드가 실행되지만 이전 뷰가 계속 표시되고 뷰 컨트롤러가 스택에서 제거되지 않아 뷰의 해고도 표시되지 않으며 적용되지 않습니다. 반면에 applicationWillEnterForeground의 코드는 실행되고 으로 적용됩니다. dismissModalViewControllerAnimated는 실제로 뷰를 전환하고 스택에서 뷰 컨트롤러를 제거합니다.UIApplicationDelegate applicationWillResignActive 메서드를 실행하고 있지만 효과를 표시하지 않습니다.

Warning: Attempt to dismiss from view controller <UINavigationController: 0x1e074c90>  while a presentation or dismiss is in progress! 

가 어떻게 적용 및 뷰의 transisions을 표시하고 스택에서 뷰 컨트롤러를 제거 dismissModalViewControllerAnimated을 강제 할 수

나는이 경고를 얻을? applicationWillEnterForeground에 포함 된 경우
#pragma mark - AppDelegateDelegate 

- (void)resetApp:(AppDelegate *)appDelegate 
{ 
    [SVProgressHUD dismiss]; 
    [[EmployeeAPIClient sharedInstance] logout]; 
    [self dismissModalViewControllerAnimated:NO]; 
} 

그러나

- (void)applicationWillResignActive:(UIApplication *)application 
{ 
    [self initializeState]; 
} 

- (void)initializeState 
{ 
    [self.appDelegateDelegate resetApp:self]; 
} 

... : 당신이 해고하려는 뷰 컨트롤러에서 제대로

- (void)applicationWillEnterForeground:(UIApplication *)application 
{ 
    [self initializeState]; 
} 

답변

0

작동 NSNotification 관찰자를 사용하려고 :

-(void)viewDidLoad{ 
    [super viewDidLoad]; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismissThisViewController) name:UIApplicationWillResignActiveNotification object:nil]; 
} 

-(void)dismissThisViewController { 
    [self dismissViewControllerAnimated:NO completion:nil]; 
}