2011-01-20 3 views
2

누군가 내 앱을 사용하고 설정 번들의 설정을 변경한다고 가정 해 봅시다. 내 앱으로 돌아 왔을 때 내보기가 해당 설정에 따라 (내 업데이트 방법을 통해) 업데이트되도록하고 싶습니다. 나는 여러 가지 일을 시도했지만 그저 작동시킬 수는 없습니다.내 앱이 다시 활성화되면 내보기를 다시로드하는 방법?

내 iPhone 응용 프로그램에 대해 이러한 종류의 동작을 구현하는 가장 좋은 방법은 무엇입니까? 당신의 AppDelegate 넣어 이러한 방법에

답변

3

AppDelegate에 국한되지는 않습니다. NSNotification을 사용하여 코드의 아무 곳에서나 이러한 이벤트를들을 수 있습니다. UIApplicationDidBecomeActiveNotification 수신하는 방법에 대한 자세한 내용은 this answer을 참조하십시오.

+0

흥미롭게도 알림이 해고되었다는 것을 알지 못했습니다! –

6

:

- (void)applicationWillEnterForeground:(UIApplication *)application { 
    /* 
    Called as part of transition from the background to the active state: here you can undo many of the changes made on entering the background. 
    */ 
} 


- (void)applicationDidBecomeActive:(UIApplication *)application { 
    /* 
    Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 
    */ 
} 

그런 다음 당신은 당신이 원하는대로 할 수있는 후크가 있습니다.

관련 문제