【问题标题】:How to see Print Debugging While Interface Builder Previews? IOS / XCodeInterface Builder 预览时如何查看打印调试? IOS / X代码
【发布时间】:2018-10-09 01:58:19
【问题描述】:
当 Interface Builder 显示 ViewController 的预览时,它必须执行属于该 VC 中包含的视图的代码才能绘制它们,对吗?
所以...假设您在自定义视图中有一些打印调试...
print("draw() was executed")
...当 Interace Builder 处理预览时,如何才能看到此输出?
谢谢!
【问题讨论】:
标签:
xcode
debugging
storyboard
interface-builder
preview
【解决方案1】:
据我所知,当 Interface Builder 执行您的代码时,无法打印到调试控制台。不过,我确实发现暂时将消息添加到 label 或 textview 是有帮助的。
如有必要,您可以执行仅在 Interface Builder 运行(或不运行)时执行的条件代码,如下所示。这样,您可以显示一个仅在设计时可见的小消息视图,否则隐藏。
#if TARGET_INTERFACE_BUILDER
// IB only
#endif