2016-11-24 2 views
2

내 앱이 백그라운드에서 실행됩니다. 다시 열면 동일한 페이지가 표시됩니다.Suspended 상태로 들어가면 AppDelegate의 어떤 메소드가 호출 될 것입니까?

iOS가 앱을 일시 중지 상태로두면 아직 메모리에 있습니다. 내가 다시 돌아 오면 어떤 AppDelegate 메서드가 호출 될 것입니다.

사실 내 목적은 종료되지 않은 경우 동일한 화면을 일시 중지 된 앱에서 복원하는 것입니다.

마지막으로 앱이 일시 중지 상태에서 돌아 오는 경우 마지막으로 Will FinishedLaunchWithOptions가 호출됩니다.

감사합니다 ..

+1

이 경우 iOS의 [보존 및 복원 상태] (https://developer.apple.com/library/content/featuredarticles/ViewControllerPGforiPhoneOS/PreservingandRestoringState.html) 기능을 사용하는 것이 좋습니다. – dive

+0

App이 종료되고 시작된 경우 복원 된 ViewController로 이동합니까 아니면 처음부터 시작하나요? @잠수 –

답변

3

Apple Documentation으로 미국,

  • 응용 프로그램 : willFinishLaunchingWithOptions : -이 방법은 실행시에 코드를 실행하는 앱의 첫 번째 기회입니다.

  • 응용 프로그램 : didFinishLaunchingWithOptions : -이 방법을 사용하면 사용자가 으로 앱을 표시하기 전에 최종 초기화를 수행 할 수 있습니다.

  • applicationDidBecomeActive : - 앱에 포어 그라운드 앱이 될 것임을 알립니다. 마지막 순간에이 방법을 사용하십시오
    준비.

  • applicationWillResignActive : - 앱이 포 그라운드 앱에서 전환되고 있음을 알 수 있습니다. 이 방법을 사용하여
    앱을 대기 상태로 만듭니다.

  • applicationDidEnterBackground : 귀하의 앱이 현재 백그라운드에서 실행 중이며 언제든지 일시 중지 될 수 있습니다.

  • applicationWillEnterForeground : - 앱이 배경에서 벗어나 전경으로 돌아 왔지만 다시 활성화되었음을 알 수 있습니다. 아직 활성화되지 않았습니다.

  • applicationWillTerminate : - 앱이 종료 중임을 알 수 있습니다. 앱이 일시 중지 된 경우이 메소드는 호출되지 않습니다.

그래서 applicationWillEnterForegroundapplicationWillResignActive가 호출되는 것입니다!

1
- (void)applicationWillResignActive:(UIApplication *)application { 
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 
} 


- (void)applicationDidEnterBackground:(UIApplication *)application { 
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 
} 


- (void)applicationWillEnterForeground:(UIApplication *)application { 
// Called as part of the 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. 
} 


- (void)applicationWillTerminate:(UIApplication *)application { 
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 
} 

didFinishLaunchWithOptions을 didnt 호출.

0

application's life cycle에 도착하면 ios에서 앱을 일시 중지 모드로 설정하면 앱에 알림이 표시되지 않습니다. 앱이 백그라운드 모드로 들어갈 때마다 처리가 아닌 아무 것도하지 않으면 ios가 일시 중지 상태가됩니다. 그러나 일시 중지되고 메모리에 남아있는 경우 앱이 있었던 화면과 동일한 화면을 표시 할 필요가 없습니다. ios는 자동으로 앱 상태를 유지합니다. 일시 중지 모드에서 앱이 종료되는 경우에만이를 관리해야합니다. 기억에 없다. 당신이 background execution 방법의 배경에있는 실행을하지 않은 경우 당신은 저장 상태 응용 프로그램을 표시 할 수 있습니다 applicationWillEnterForeground 곳 앱 applicationDidEnterBackground 저장 상태에 대한 알림을받을 경우

, 당신은 중단 모드에서 응용 프로그램을 고려할 수 있습니다.

또는 백그라운드에서 일부 유한 작업을 실행하는 경우 로컬 변수를 유지하고 일시 중지 또는 지금 추적하는 데 사용할 수 있습니다. applicationDidEnterBackground, variable = inBackground, 작업 완료시 variable == inBackground, variable == inSuspended으로 설정하고 앱 상태를 어딘가에 저장하십시오. on applicationWillEnterForeground

0

AppDelegate 파일에서 중단 점을 사용하여 테스트 할 수 있습니다.

사용자가 홈 버튼을 한 번 클릭하면 앱이 일시 중지 상태입니다. 사용자가 홈 버튼을 두 번 클릭하면 앱이 비활성 상태입니다.

사용자가 일시 중지 상태에서 앱으로 이동하는 동안 다음 메소드 호출을 발견했습니다.

첫 번째 : applicationWillEnterForeground 다음에 applicationDidBecomeActive.

didFinishLaunchingWithOptions이 호출되지 않았습니다.

More details

관련 문제