When debugging autorun in what does masking strings mean like h = - & v = - & -?

I think they should relate to the model of struts and springs, but I can not find their mention. When restricting an NSLog they sometimes appear as a description string for the undocumented NSAutoresizingMaskLayoutConstraint class. I noticed at least 3 different types: h=--- , h=--& , h=-&- with horizontal and vertical versions.

They very often appear during debugging using limited layouts.

+48
autolayout cocoa
Jan 12 '13 at 4:02
source share
3 answers

If you specify automatic masking instead of restrictions or do not specify restrictions at all, then the view will have NSAutoResizingMaskLayoutConstraint restrictions, not NSLayoutConstraints. If you set translatesAutoresizingMaskIntoConstraints to NO , then these restrictions are not displayed. You cannot mix and match in one view, or you get unsatisfactory constraint errors.

I set up a quick test project with various combinations of autoresist masks, and the logging format is pretty simple.

  • h= or v= indicates that we are talking about bans in the horizontal or vertical direction.
  • - indicates a fixed size
  • & indicates flexible size
  • Character order represents margin, size, margin

Therefore, h=&-& means that you have left and right margins and a fixed width, v=-&- means fixed upper and lower margins and flexible height, etc.

+99
Jan 18 '13 at 22:56
source share

If you watch the WWDC 2012 video in the "Best Practices for Mastering Auto Layout" section, there is a section where the facilitator mentions that this is a syntax for representations that use autoresist and NOT masks. There is no visual format associated with them, for example for NSLayoutConstraint.

+3
Jan 18
source share

Adding jrturton to the answer, the best information I found to understand the descriptions of constraints is Visual Format documentation, which requires creating constraints in the code. The language is documented as formal grammar, so it may take a minute to absorb it all.

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/AutolayoutPG/VisualFormatLanguage/VisualFormatLanguage.html#//apple_ref/doc/uid/TP40010853-CH3-SW1

Give an example:

 <NSLayoutConstraint:0x10ada8a70 H:|-(44)-[UIButton:0x10ac5dc30] (Names: '|':UIView:0x10ac60470)> 

This is a horizontal orientation constraint ( H:) . The relationship is 44 pixels from the supervisor (|) to UIButton. The named supervisor is UIView ( Names: '|': UIView:) - it is important to know because you do not need to restrict direct viewing

Sixteen values ​​are all valid addresses of your interface elements. When you stop a point in all exceptions and suspend a conflict conflict, you can use the po address to view the constraint object. In my case:

 (lldb) po 0x10ac5dc30 <UIButton: 0x10ac5dc30; frame = (44 199; 30 30); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x10ac5ddf0>> (lldb) po 0x10ac60470 <UIView: 0x10ac60470; frame = (0 64; 320 504); autoresize = RM+BM; animations = { position=<CABasicAnimation: 0x10ac5ec70>; bounds=<CABasicAnimation: 0x10ac62250>; }; layer = <CALayer: 0x10ac60530>> 
+3
Jul 03 '14 at 13:45
source share



All Articles