WWDC 2011 Session Videos - HD 에서 autolayout 얘기 보기.
Session 302 - Using Interface builder in Xcode 4 53:44 11. 6. 16. Apple Developer Developer on iTunes
에서 auto layout 소개를 조금 들었었다. 2011/09/16 17:05 쯤.
Session 103 - Cocoa Autolayout 59:16 11. 6. 16. Apple Developer Developer on iTunes
를 꼭 봐야 했었네.
interface builder로 조작도 가능하면서도,
in-code layout도 가능하다.
guide:
http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AutolayoutPG/Articles/Introduction.html
이런 거 꼭 필요하다~.
autolayout으로 안된다면, 비슷한 걸 만들어야겠다.
springs and struts에서 이미 있는 개념인가보네.
핵심은 NSLayoutConstraint를 지정해둘 수 있고,
이 constraints가 실행 시간에 적용이 된다는 것.
controller가 layout에 대해서 모르게 하고 싶다. 나도!
헉, 그런데, ios에서 지원이 안되나보다.
http://developer.apple.com/library/mac/#documentation/AppKit/Reference/NSLayoutConstraint_Class/NSLayoutConstraint/NSLayoutConstraint.html
가 mac에서만 지원이 되네.
언젠가 ios에도 들어오겠지..
Update Constraints
NSWindow updateConstraintsIfNeeded
NSView updateConstraintsSubtreeIfNeeded
NSView updateConstraints
NSView needsUpdateConstraints
NSView setNeedsUpdateConstraints:
은 새로 나온 거겠지?
layout, display는 원래 있었던 mechanism대로 동작할 것 같다.
Layout
NSWindow layoutIfNeeded
NSView layoutSubtreeIfNeeded
NSView layout
NsView needsLayout
NSView setNeedsLayout:
Display
NSWindow displayIfNeeded
NSView displayIfNeeded
NSView drawRect:
NSView needsDisplay
NSView setNeedsDisplay:
그 외에도 baseline 을 지정하고, 이것을 이용해서 맞춰주는 기능도 있나보다.
alignment rect를 통해서, 직사각형 모양으로 맞추기
NSViewShowAlignmentRects 를 통해서 맞추는 것을 확인할 수도 있나보다.
demo를 보여주는데, ui debugging 기능이 정말 좋네.
설정만 하면, 어떤 object와 관련이 있는 alignment lines를 보여주고, 실제 내용을 알려준다.
constraint solving algorithm으로
http://www.cs.washington.edu/research/constraints/cassowary/
을 추천해주는데, 어떤 역할을 하는지 모르겠다.
---
26' 부터 다시 본다.
Display mechanism은 top-down ~> 이게 from View to Super-view??
update constraints path는 bottom-up ~> 이게 leaf --> super --> super
layout은 top down (setFrame) . 이지만 실제 layout 계산은 꼭 그렇지만은 않다고 한다. 동시에 일어나는 것도 있다.
layoutIfNeeded 가 updateConstraints 를 부른대.
이제는 setFrame 하지 말고, constraint를 update해야 한다.
animation 할 때도 constraint를 바꿔야 한다.
autolayout 을 직접 구현한다고 했을 때, 이런 게 부담이 될 수도 있겠네.
slide를 보는 것이 최고.
RECENT COMMENT