如何检测和实现单击主页按钮的触摸事件?

How to detect and implement touch events for single tap on home button?

不确定是否可行,但有什么方法可以检测到主页按钮上的单次触摸。首先,如果用户在主页按钮上按下一次(没有实际按下),我只想添加一个 NSLog,但我不知道我应该在哪里添加此功能。 Apple 是否允许您与主页按钮进行交互?

我查看了应用程序委托方法,但我看不出任何方法在单击(触摸)上下文中如何工作。非常感谢您的帮助。

Does Apple allow you to interact with the home button?

不,还没有。没有可用于 显式 检测主页按钮交互的 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:.
}