Autolayout断点调试
来源:互联网 发布:重庆seo服务外包 编辑:程序博客网 时间:2024/06/08 09:41
文章转自:博客
Autolayout Breakpoints
Auto layout has become a crucial tool for iOS and OS X development. It makes creating layout for multiple screen sizes easy peasy. But sometimes it can drive you crazy, with verbose and misleading logs.
Unable to simultaneously satisfy constraints.Probably at least one of the constraints in the following list is one you don't want.Try this:(1) look at each constraint and try to figure out which you don't expect;(2) find the code that added the unwanted constraint or constraints and fix it.(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)(...........)Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
That’s a huge log! And I cut off the NSLayoutConstraint
part. Yet, the second last line is giving a clue in which direction to go to fix this issue. Symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints
.
All right, here’s what Xcode want’s you to do:
Honestly, that won’t help much, because basically it’ll just stop the execution and leave you up with LLDB, alone in the dark.
But there’s a little trick you can do to enhance the preceding symbolic breakpoint. Adding po [[UIWindow keyWindow] _autolayoutTrace]
to it (for Obj-C projects) or expr -l objc++ -O -- [[UIWindow keyWindow] _autolayoutTrace]
(for Swift projects).
Now, on console, you’ll see all the UIView
hierarchy and exactly where it has ambiguity.
UIWindow:0x7f9481c93360| •UIView:0x7f9481c9d680| | *UIView:0x7f9481c9d990- AMBIGUOUS LAYOUT for UIView:0x7f9481c9d990.minX{id: 13}, UIView:0x7f9481c9d990.minY{id: 16}| | *_UILayoutGuide:0x7f9481c9e160- AMBIGUOUS LAYOUT for _UILayoutGuide:0x7f9481c9e160.minY{id: 17}| | *_UILayoutGuide:0x7f9481c9ebb0- AMBIGUOUS LAYOUT for _UILayoutGuide:0x7f9481c9ebb0.minY{id: 27}
Note that as you hit continue it’ll stop at every ambiguous layout you may have. And if that’s not enough for you to find out your autolayout issue, try changing the view’s color, who knows?
(lldb) expr ((UIView *)0x7f9ea3d43410).backgroundColor = [UIColor redColor](UICachedDeviceRGBColor *) $1 = 0x00007f9ea3d43410
Fear no more young Padawan, make symbolic breakpoints and LLDB work for you!
I would like to thank Porter Hoskins for pointing out the correct LLDB command for Swift.
by Rafael Machado, 2015 Aug 17
Tweet
- Autolayout断点调试
- 断点调试
- 断点调试
- 断点调试
- 断点调试
- 断点调试
- 断点调试
- 断点调试
- 断点调试
- 断点调试
- 断点调试
- 断点调试
- 断点调试
- 断点调试
- 断点调试
- MyEclipse断点调试 ,JavaScript断点调试
- eclips 断点调试,android断点调试
- java的断点调试
- strace命令用法详解
- Caliburn Micro Part 6: Introduction to Screens and Conductors
- Visual Studio 2013中的源代码管理工具Git的使用
- Android-非常棒的HTTP通讯总结
- android开发之重写Application类
- Autolayout断点调试
- USB系统设备模型建立流程
- 【Python】关于递进错误indentationerror
- 【system】linux 常用命令
- hdoj 3665 Seaside
- Linux 中用 strace 追踪系统调用和信号值
- HDOJ 1407 测试你是否和LTC水平一样高
- [LeedCode OJ]#237 Delete Node in a Linked List
- PPT制作滚动文本的方法