0

I need to create a view controller like this or like user instagram's profile

enter image description here

not exactly same, I just want to add label and buttons and collection view, but I want all of this in scroll viewController
I think I can't do that from storyboard, so how I can make a view controller scrollable programmatically?
and then I want to add the label and buttons inside the scroll , I can do that programmatically , but how I can add collection programmatically inside it?

Community
  • 1
  • 1
joda
  • 711
  • 2
  • 8
  • 16
  • Why are use programmatically ? I suggest story board for easy of adding and arranging objects.. – Rajamohan S Sep 27 '16 at 03:54
  • @MohanSingh how I can do that in story board? I need the viewcontroller scrolling when I have a long text in the label – joda Sep 27 '16 at 04:56
  • sorry i not able to understand what you exactly need. i said depend on that image, Use scroll view . if you need change height of the `view` on story Bord follow this link. http://stackoverflow.com/questions/39301896/how-to-use-storyboard-to-lay-out-screen-content-that-is-taller-than-the-screen-o – Rajamohan S Sep 27 '16 at 05:59
  • @MohanSingh thank you that is exactly what I need!! but the point I want to add some label in this scrollView, the contents and height of the label depend on what the user entered in it , so the height of contentView not fixed, its should depend on label height and other objects in the viewcontroller, how I can do it? – joda Sep 27 '16 at 10:59

1 Answers1

1

One of the possible solutions is to make the whole container a "UICollectionView" -or "UITableView", depends on what exactly you want to build-, and then, create a custom cell for each area depending on what do you want to display in it.

It might sounds a little bit strange in the beginning, but you will notice that it is a great technique to handle scrolling in your scene, including some of extra nice features, such as:

  • auto scroll content resizing for "UIKeyboardWillShowNotification" and "UIKeyboardWillHideNotification" events.
  • the ease of showing and hiding sections from the UI (actually they are cells!).

UPDATED: For example:

enter image description here

You can make the first part (red rectangle) as a UICollectionReusableView and customize it by adding your images and button in it, second part (blue square) as a UICollectionViewCell and so on...

This is the general idea of what how you can do it.

Ahmad F
  • 30,560
  • 17
  • 97
  • 143