2017-02-20 11 views
0

가능한지 확실하지 않지만 홈 버튼에서 한 번 터치하는 것을 감지하는 방법이 있는지 확인하십시오. 우선, 사용자가 홈 버튼을 한 번 눌러 (실제로 누르지 않고) NSLog를 추가하기를 원하지만,이 기능을 어디에 추가 할 것인지 모르겠습니다. Apple에서 홈 버튼과 상호 작용하도록 허용합니까?홈 버튼에서 한 번의 탭에 대한 터치 이벤트를 감지하고 구현하는 방법은 무엇입니까?

응용 프로그램 대리인 메서드를 살펴 보았지만 단일 탭 (터치) 컨텍스트에서 어떻게 작동하는지 알 수 없습니다. 당신의 도움에 정말로 감사 할 것입니다.

+0

홈 버튼을 탭하면 앱이 '배경'모드로 이동합니다. AppDelegate의 방법으로 논리를 작성할 수 있습니다 : - 'applicationDidEnterBackground' – pkc456

+0

안녕하세요 @ pkc456'누르기 '는'누르기 '가 아니라'누르기 '를 의미합니다 - 클릭하지 않고 홈 버튼을 한 번 터치하기 만하면됩니다. – hinterbu

답변

1

Apple에서 홈 버튼을 사용할 수 있습니까?

아니요, 아직 없습니다. 에 사용할 수있는 API가 없습니다. 홈 버튼 상호 작용을 감지합니다.
기존의 app delegate주기 함수 호출을 사용하여 원하는 모든 논리를 수행 할 수 있습니다.

- (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)applicationWillTerminate:(UIApplication *)application 
{ 
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 
} 
+0

Ah. 이러한 메소드는 모두 앱이 종료되거나 비활성화 될 때와 관련이있는 것으로 보입니다. 맞습니까? 앱이 정상적으로 실행되는 동안 앱이 여전히 활성화되어있는 동안 언제든지 홈 버튼을 한 번 터치 할 수 있습니까? – hinterbu

+0

@hinterbu 아니오, 홈 버튼이 이벤트 API를 사용할 수 없습니다. 응용 프로그램은 장치의 홈 단추에서 모든 터치/탭을 해독 할 수 없습니다. – ystack