Mike Simz Mike Simz - 1 year ago 108
iOS Question

Building a Profile Screen like Instagram

So I'm in the process of building an application on iOS that requires a very similar profile view like Instagrams (for iOS). My question is what is the best way to do this - Instagram's profile screen consists of a personal view with your picture, stats, etc. as well as a tab bar like control that allows you to switch between multiple views underneath your personal view. These views are either a table view or a collection view. I am able to swap the view at the bottom between different table views/collection views but instagram has it setup where the whole profile screen scrolls as one scroll view or table view. How do I achieve this or what is the best way to go about building this out?

Any help would be greatly appreciated. Thanks in advance!

Answer Source

You must have add that whole view into a scrollview.

Disabled the scrolling of tableview which has multiple posts.

After that, change the frame of tableview according to its row or number of counts in array. Like, You have 10 posts for showing in table view. and height of row for that tableview is 100. So,

tableview.frame = CGRectMake(tableview.frame.origin.x, tableview.frame.origin.y, tableview.frame.size.width, 100*10);

After that, change the content size of scrollview.

myScrollView.contentSize = CGSizeMake(myScrollView.frame.size.height,
                                  tableview.frame.origin.y + tableview.frame.size.height);


If your TableView's height is changing with every cell, then just use following line:-

myScrollView.contentSize = CGSizeMake(myScrollView.frame.size.height,
                                  tableview.frame.origin.y + tableView.contentSize.height);

Then you got the view same as profile view of Instagram.

Don't forgot to disable scrolling of tableview.

I am sure that, this solutions helps you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download