티스토리 뷰

 

 

 

나의 stackview에 코드로 NSTextField를 만들어서 하나씩 addSubview 해줬는데... 안보여서 로그 찍어보니 0 0 으로 설정되어 있었다. 왜...? 나의 stackview는 fill equally 속성인데 대체 왜;;;;

 

그래서 해본 시도

1. 코드로 stackView.translatesAutoresizingMaskIntoConstraints = false 로 지정해준다. 

 

translatesAutoresizingMaskIntoConstraints 은 Auto resizing mask를 constraints로 바꾸는걸 동의하는지 묻는 것이다.

When this property is set to true, the view’s superview looks at the view’s autoresizing mask, produces constraints that implement it, and adds those constraints to itself (the superview). If your view has flexible constraints that require dynamic adjustment, set this property to false and apply the constraints yourself. 

얘가 true로 지정 되어 있으면, superview가 Auto resizing mask을 보고 constraint를 자동으로 만들어서 붙혀준다. 

 

하지만 이건 효과가 없었다. 

 

2. cell.stackView.addArrangedSubview(field)로 함수를 바꿈

 

addSubview()

addArrangedSubview()

둘의 차이는...?!

 

A UIStackView, as might be guessed from its .addArrangedSubview() method, arranges its subviews, based on its .axis, .alignment, .distribution and .spacing properties, as well as its frame.

 

 

Adding it as a subview simply overlays the button on the stack view, instead of allowing the stack view to arrange it, and your stack view likely then has a height of zero -- so the button cannot be tapped.

 

그러므로 addArrangedSubview()를 써야했던것..

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함