问题描述:

So I've created an IBCollection Outlet in swift. Basically it is an array [UIButton]

I have an IBAction that creates a new button called button and appends it to the array. So basically when I click a certain button, it adds other buttons. What I cannot figure out is how to get those buttons to then autolayout.

Any ideas?

I really appreciate any help. Thank you so much

网友答案:

So, you want to autolayout programatic buttons.

First question is... are you getting these to lay out at all? Are they appearing in the view in any shape or form? If not, then your issue not an autolayout one, but rather, just an issue of adding them to the view (addsubview:)

If they are getting added, but autolayout is not toggling, you need to set constraints.

I suggest read this apple doc - it hits your nail right on the head!

https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/AutoLayoutinCode/AutoLayoutinCode.html

相关阅读:
Top