Just a coder
Just a coder

Reputation: 16700

How to setup a UIScrollView to arrange content dynamically?

I am trying to create a user profile screen. The screen will have lots of information about a user. It will look similar to this AirB

enter image description here

From the looks of it, it seems to be some sort of scrollView? or is it a tableView or a collectionView? (because it seems that there are some rows in there i think)

Does any one here know how this type of view can be accomplished or can be setup?

EDIT two answers below says to use a UITableview, and 2 other answers says to avoid it. Are there any benefits/disadvantages to using either?

Upvotes: 0

Views: 213

Answers (4)

Ali Riahipour
Ali Riahipour

Reputation: 524

Use only one child UIView as i will call it ContainerView inside UIScrollView and then place your child views inside that ContainerView. Use constraint to trailing and leading and top and bottom of that ContainerView to UIScrollView. and use constraint for placing child views to viewController.view not to ContainerView to then iOS will find where child views have to be.

Good Tutorial to find out how to use constraint on scrollView

Apple Technical Note

Upvotes: 1

Vijay Palwe
Vijay Palwe

Reputation: 109

In one of my app i did same thing using Tableview. And for that tableview i created a custom cell which have such a big height and i added all the images,map,details of user in that. And it work similar to what you want. If you want help reply to my answer

Upvotes: 0

DeyaEldeen
DeyaEldeen

Reputation: 11807

Do Not use tableview in this case, this content is difficult to maintain in a table view, really, use a scrollview, as for how, a simple googling for "swift uiscrollview tutorial"

Upvotes: 1

Reshmi Majumder
Reshmi Majumder

Reputation: 961

Tableview is the best solution for this kind of scrolling views but in the screen you have mapview if it updates every moment i.e. updates with current location then it is not recommended to use tableview.

In that case you can use scrollview with custom views add subview changing with parameters.

Upvotes: 0

Related Questions