1

はい、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];
4

1 に答える 1

0

デバッグフラグの使用方法は次のとおりです

#if DEBUG == 1
#define CMLog(format, ...) NSLog(@"%s:%@", __PRETTY_FUNCTION__,[NSString stringWithFormat:format, ## __VA_ARGS__]);
#define MARK    CMLog(@"%s", __PRETTY_FUNCTION__);
#define START_TIMER NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate];
#define END_TIMER(msg)  NSTimeInterval stop = [NSDate timeIntervalSinceReferenceDate]; CMLog([NSString stringWithFormat:@"%@ Time = %f", msg, stop-start]);
#else
#define CMLog(format, ...)
#define MARK
#define START_TIMER
#define END_TIMER(msg)
#endif

そして、ここにスクリーンショットがあります

ここに画像の説明を入力

リリース設定でもフラグを0にしてこのように -DDEBUG=0

このようにして、達成したいことを達成できます。それが役立つかどうか教えてください。

于 2011-07-23T03:53:43.900 に答える