1
  • UIStackView(main)
    • UIView(sub)
      • UILabel,UIButton etc.
    • UIview (sub)
    • may be others views

All these are programmatically with constraints. And may be UIView of UILabel or UIButtons are create into loops. One by One.

Please help !!

9
  • Why do you use no UITableView or UICollectionView? They simplify subview creation and layout as well as having a better memory usage. They are both designed for displaying a dynamic count of subviews. Commented Nov 3, 2016 at 6:56
  • b'coz I want to create dynamic. I don't know which UI type become first or last. But every view is in it's super view and may be it's expandable. Commented Nov 3, 2016 at 7:11
  • I see no reason for not using a collection or table view even after your explanation. Commented Nov 3, 2016 at 7:20
  • My views are not fix or how many it is. It's depend on sever response and UI types also. Commented Nov 3, 2016 at 7:23
  • Table and collection views are designed for a dynamic number of subviews, and you can always change the number of displayed cells without reloading the full view. You can have multiple cell types with completely different layouts. If you have too many subviews in your stackview, you will get both serious memory and performance problems, while table and collection views will handle very huge numbers of cells without problems. Commented Nov 3, 2016 at 7:29

2 Answers 2

1

If you want to create these views programatically, i would recommend these two libraries. They make adding/removing/updating/managing constraints very easy.

Objective-c

https://github.com/SnapKit/Masonry

Swift

https://github.com/SnapKit/SnapKit

Sign up to request clarification or add additional context in comments.

Comments

1

You can use apple Native NSLayoutAnchor to create constraints programatically. Which is sort and simple like SnapKit/Masonry.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.