2011-12-10 1 views
4

사용자가 집 버튼을 클릭하여 응용 프로그램으로 돌아 오는 경우 응용 프로그램에서 해당 작업을 인식하고 사용자가 볼 수 있도록 메시지를 생성하도록 (예 : 다시 돌아올 수 있도록) 설계하고 싶습니다. 나는 이것을 위해 appdelegate를 수정해야한다고 생각하지만 코딩하는 법을 모른다. 누구든지 손을 빌릴 수 있을까?내 앱이 홈 버튼을 감지하도록하려면 어떻게합니까?

+0

이 iOS 또는 Mac OS X입니까? 그에 따라 질문에 태그를 달아야합니다. – millimoose

+6

나는 홈 버튼이 iOS 장치에만 존재한다고 생각한다. – Saurabh

답변

5

배경에서 응용 프로그램 웨이크 업 .. 그것은 응용 프로그램 대리인이 위임에 올 때마다 -

- 당신은 또한

이 대표를 확인이 위임에 사용자에게 MSG를 표시 할 수 있습니다

- (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)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 throttle down OpenGL ES frame rates. 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:. 
    */ 
} 
+1

대신에 -applicationWillEnterForeground :를 사용하고 싶을 것이다. 그렇지 않으면 경고를 포함한 다른 많은 것들을 트리거 할 것이다. – BoltClock

+0

예 .. 당신 말이 맞아요. – Saurabh

관련 문제