开发者

Subclassing UIWindow - Need Preprocessor Help

Yes, I know subclassing UIWindow is frowned upon, but my subclassed UIWindow is for debugging purposes only (it takes a screenshot of the current-page once a specific motion event is detected).

Anyway, I made a custom precompiler flag called DEBUG in my project's Build Settings, but I'm having a problem getting it to load/function properly. Right now, it's not taking the screenshot, but it is registering the occurrence of the motion event.

Here's the code I have in the AppDelegate's 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 =开发者_JAVA百科 _window;
#endif

    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];


Here is how to use debug flag

#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

And here is the screenshot

Subclassing UIWindow - Need Preprocessor Help

Also in the release setting put the flag to 0 Like this -DDEBUG=0

This way you can achieve what you want to achieve.Let me know if it helps or not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜