2011-05-02 3 views
3

안녕하세요, 저는 이것이 아주 솔직한 것이라고 확신하지만 어디에서나 정보를 찾을 수 없습니다. 배경에서 열 때 일부 정보를 다시로드하려면 앱이 필요합니다 (새로 열지는 않음). 어떤 아이디어로 그렇게 할 수 있습니까? 잠자기에서 앱 가져 오기 기능 실행

답변

5

앱이 UIApplicationDelegate- (void)applicationWillEnterForeground:(UIApplication *)application을 대체 할 수 있습니다.

또한 컨트롤러를 UIApplicationWillEnterForegroundNotification의 옵서버로 설정하십시오. Apple Docs에 따르면 : 응용 프로그램이 활성 상태가되는 도중에 백그라운드 상태를 떠나기 직전에 게시됩니다. NIB 파일에서 컨트롤러

샘플 코드, 그렇지 않으면 - (id)init를 오버라이드 (override) : 완벽한 소리

- (void)awakeFromNib { 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wakeUp:) name:UIApplicationWillEnterForegroundNotification object:nil]; 
} 

- (void)wakeUp:(NSNotification *)pNotification { 
    NSLog(@"Name: %@", [pNotification name]); 
    NSLog(@"Object: %@", [pNotification object]); 
    NSLog(@"I am waking up"); 
} 

- (void)dealloc { 
    [[NSNotificationCenter defaultCenter] removeObserver:self]; 
    [super dealloc]; 
} 
+0

그것은 완벽하게 들린다. 어떤 아이디어를 어떻게 내 View Controller에서 실행시킬 수 있습니까? – Rob

+0

@Rob, 내 대답에 샘플 코드를 추가했습니다. –

+0

어떤 이유로 작동하지 않음 = S – Rob

관련 문제