autolayout學習筆記_2
一個在控制皮膚獲取autolayout的_autolayoutTrace的小技巧
add the debugging code to ViewController.m:
@interface UIWindow (AutoLayoutDebug)
+ (UIWindow *)keyWindow;
- (NSString *)_autolayoutTrace;
@end
And:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSLog(@"%@", [[UIWindow keyWindow] _autolayoutTrace]);
}
- (void)didRotateFromInterfaceOrientation: (UIInterfaceOrientation)fromInterfaceOrientation
{
[super didRotateFromInterfaceOrientation: fromInterfaceOrientation];
NSLog(@"%@", [[UIWindow keyWindow] _autolayoutTrace]);
}
I like to have this tracing code in there so that it’s easy to spot ambiguous layouts. Interface Builder works hard to prevent you from making mistakes, but when you’re building up your constraints programmatically, you can do all sorts of things wrong.
Sometimes your layout may even appear to work just fine, but then you do an _autolayoutTrace and it actually says AMBIGUOUS LAYOUT. You want to catch such errors before you ship your app to customers. It’s better to be on the safe side, especially when you’re just starting out with Auto Layout.
相關文章
- Autolayout學習筆記筆記
- iOS Autolayout筆記iOS筆記
- Vue學習筆記2Vue筆記
- MySQL學習筆記2MySql筆記
- RocketMQ學習筆記 2MQ筆記
- Oracle學習筆記2Oracle筆記
- react學習筆記2React筆記
- mysql學習筆記-2MySql筆記
- jQuery學習筆記(2)jQuery筆記
- Scala學習筆記2筆記
- TestNG—學習筆記2筆記
- 學習筆記2(下)筆記
- koa2學習筆記筆記
- hibernate學習筆記(2)筆記
- Python學習筆記(2)Python筆記
- Android學習筆記(2)Android筆記
- koa@2學習筆記筆記
- C#學習筆記2C#筆記
- db2學習筆記DB2筆記
- 藍芽學習筆記2藍芽筆記
- PL/SQL學習筆記-2SQL筆記
- iproute2學習筆記筆記
- Flex學習筆記(Day 2)Flex筆記
- 2-SAT 學習筆記筆記
- 強化學習-學習筆記2 | 價值學習強化學習筆記
- ASP.NET學習筆記2ASP.NET筆記
- Ext2.x學習筆記筆記
- 學習筆記(2)IPC機制筆記
- LevelDB 學習筆記2:合併筆記
- G01學習筆記-2筆記
- CryptoZombies學習筆記——Lesson2筆記
- <node.js學習筆記(2)>Node.js筆記
- docker學習筆記(2)- 倉庫Docker筆記
- 人工智慧學習筆記(2)人工智慧筆記
- angular學習筆記(十四)-$watch(2)Angular筆記
- angular學習筆記(七)-迭代2Angular筆記
- railscasts學習筆記(5-2)AIAST筆記
- DB2-utilities學習筆記DB2筆記