0

I have a view that I need to build in IOS.

It is a user profile view.

Basically I present the user profile such as name, age, gender, nationality

Each of these field is a slightly different UI control, therefore I cannot simply use a UITableView and UITableViewCell.

Is there a way to simply put a bunch of different views one by one and then have the whole screen to be scrollable?

What is the simplest way to construct such a view? Is it possible to implement it with only one view in storyboard, and one viewcontroller file for this view?

(I did it in android with a single layout, and then simply query for data in the activity and then set values for labels one by one.

Zhen Liu
  • 7,550
  • 14
  • 53
  • 96

1 Answers1

0

Each of these field is a slightly different UI control, therefore I cannot simply use a UITableView and UITableViewCell.

That's incorrect.

You can have multiple different cells with completely different UI. Just subclass them and add your custom UI to them.

Return the cell you want for the indexPath you need it to in the tableView(_:cellForRowAt:) method.

Example tutorial by Stan Ostrovskiy:

enter image description here

  • OK... i see. This is a really weird approach for me from an android perspective. But I guess I will just have to do it this way. Is there no way to layout the entire view once, and not care about cells? It seems to be really over engineering because i know 100% that they will not be reused. – Zhen Liu Feb 27 '17 at 15:44
  • @user1017674 You can look for that answer in details here: http://stackoverflow.com/questions/37938809/how-to-prevent-uitableview-from-reuse-custom-cells-swift However, this is the best way to go, you have all the delegate and datasource methods handed to you for the customizing UI , what to show where to show etc, instead of a messy custom UIScrollView where you have do do all the dirty code yourself. Most apps nowadays consist of exclusivly tableviews/collectionviews or UIStackViews –  Feb 27 '17 at 15:54