UIDebuggingInformationOverlay调试视

2017-06-01  本文已影响0人  迈克学

原文链接

方法一 (启动直接显示)

需要写在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

ifdef DEBUG

pragma clang diagnostic push

pragma clang diagnostic ignored "-Warc-performSelector-leaks"

id debugClass = NSClassFromString(@"UIDebuggingInformationOverlay");
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
    [debugClass performSelector:NSSelectorFromString(@"prepareDebuggingOverlay")];
});
id debugOverlayInstance = [debugClass performSelector:NSSelectorFromString(@"overlay")];
[debugOverlayInstance performSelector:NSSelectorFromString(@"toggleVisibility")];

pragma clang diagnostic pop

endif

方法二 (双指同时点击状态栏显示)#推荐#

需要写在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

ifdef DEBUG

pragma clang diagnostic push

pragma clang diagnostic ignored "-Warc-performSelector-leaks"

//可视化调试
Class overlay = NSClassFromString(@"UIDebuggingInformationOverlay");
[[overlay class] performSelector:NSSelectorFromString(@"prepareDebuggingOverlay")];

pragma clang diagnostic pop

endif

效果

上一篇下一篇

猜你喜欢

热点阅读