基于 UIWindow 的子类,能够检测摇晃、状态栏点击、长按、触摸开始/移动/结束/取消,通过 NSNotification。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIViewController* rootViewController = self.window.rootViewController;
// replace UIWindow with YIDetectWindow
YIDetectWindow* window = [[YIDetectWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
window.detectsShake = YES;
window.detectsStatusBarTap = YES;
window.detectsTouchPhases = YES;
window.detectsLongPress = YES;
self.window = window;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
extern NSString* const YIDetectWindowDidReceiveShakeNotification;
extern NSString* const YIDetectWindowDidReceiveStatusBarTapNotification;
extern NSString* const YIDetectWindowDidReceiveTouchesBeganNotification;
extern NSString* const YIDetectWindowDidReceiveTouchesMovedNotification;
extern NSString* const YIDetectWindowDidReceiveTouchesEndedNotification;
extern NSString* const YIDetectWindowDidReceiveTouchesCancelledNotification;
extern NSString* const YIDetectWindowDidReceiveLongPressNotification;
YIDetectWindow
在 Beerware 许可证下可用。
如果我们某天相遇,你觉得这些材料很有价值,你可以买我一杯啤酒作为回报。