是的,我知道子类化 UIWindow 是不受欢迎的,但我的子类化 UIWindow 仅用于调试目的(一旦检测到特定的运动事件,它会截取当前页面的屏幕截图)。
DEBUG
无论如何,我在我的项目的Build Settings中创建了一个自定义预编译器标志,但是我在让它正常加载/运行时遇到了问题。现在,它不是截取屏幕截图,而是记录运动事件的发生。
这是我在 AppDelegate 中的代码 didFinishLaunchingWithOptions:
#if DEBUG
DebugWindow *debugWindow = [[DebugWindow alloc] init];
self.window = debugWindow; //'window' is declared in the AppDelegate's @interface file and synthesized as window=_window in the @implementation file
#else
self.window = _window;
#endif
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];