UITableView with multiple types of cells - ios

What is the best approch to make feed view like shown in picture ?
One approach I know is One section per post and multiple rows for internal content.
But when there is repeating content like Comments here what to do ? I am looking for better approach.
Help!!

You can add a UITableView as a subview of a UITableViewCell! It can get a bit hairy when creating a data source for such a thing, so it's best not to use the same ViewController as the delegate for your main table and each cells table.

Related

Looking for the best scroll-view solution

I want to learn and implement the most suitable/simple solution to display dynamic data (JSON) in three lines and an active (clickable) download icon. Screenshot is attached
I would be glad to get your ideas and advice!
Thanks
UITableView is the way to go, as you can reuse a custom cell you define. And to add to that, UITableView's cells are loaded lazily and are reused. You can use a UIScrollView but if you have a lot of rows it can horde your memory real fast. In your case, a UIScrollView can be used as well, but if you plan on expanding, UITableViews would be the choice. All in all, go with a UITableView + a custom UITableViewCell
If you have array of data like this, the best way is using UITableView class. With UITableview, you can custom your UITableViewCell on the fly

IOS table view inside of a table view

I have a table view with expanding cells for each of them. I want to make every expanding cell be a new table inside of the bigger one. Is that possible? I've done the research, someone said that duplicate UITableView cannot put in one file.
For example
dish order1
=================
dish order2
rice
coke
===============
dish order3
which every "dish order #" is a cell of a table, and when you expand one cell, there will be a smaller table appears. I've done all the expanding stuff. But don't know how to put a small table into a bigger one. Thanks
Well if i understand your question correctly, what you search is called nested tableView, here's some examples:
SDNestedTable
ExtensiveCell
CollapseClick
JKExpandTableView
Good luck.
It would likely be impossible to put one table view inside of another table view, and if you did manage to do it, it would be awful. Ask yourself, have you EVER seen this in a commercial app? If not, as a novice iOS developer, you are out of your depth trying to invent new UI paradigms.
Master the existing UI tools first. Don't try to use the UI elements in totally novel ways until you have a strong feel for the standard way to use them. Expect this to take 6 months or more.
Others have suggested a sectioned table view where initially only the first element of a section is visible, but when you tap on it, it expands to add other rows. This works quite well.
Another approach would be to use a master/detail UI, where tapping on one table view cell pushes a new view controller the uses a new table view to display detail information about the previously selected item. There are some use cases where you might have several levels of increasing detail.
I really do not think you want two instance of UITableView, instead what you want is a sectioned UITableView which expands when it's header is tapped. Apple has a good sample code for this here:
UITableView expand/collapse
i have demo for you , just got from github..
https://github.com/mitsBhadeshiya/ExpandingCell
i hope this is helpfull for you...
Have you considered using one UITableView with multiple sections? You can accomplish what you are depicting above with only one tableView.
Since this was a problem for many people in the past, iOS 9 has a thing called Stack View, it does exactly what you are saying.
Check out this article.

iOS Design implementation recommandations

I would like to know how to handle, for my iOS app, the following situation:
I have to deal with something like this (basicly this is an article with comments, received from a server):
=- Text and Images -=
=- UIWebView -=
=- List of Comments -=
Now, I came up with two solutions:
Have the content above the list of comments wrapped in a UIScrollView, and create Views for each and everyone of the comments (don't know many of them could be), and
Make the list of comments a UITableView, and the above content its Header.
Which of these (or possibly another if you have any recommandations) should I choose? It may look not very important, but I would like to know this, so I could use the idea in further developing.
I would use a UITableView with a custom UITableViewCell wich holds the comments.
It will definitely have a better performance the UITableView than the UIScrollView since the UITableView re-uses the cells.
Using a UITableView you will just have to worry about customising the cells for the comments.
Otherwise if you want to use the UIScrollView in case you have a lot of comments you will have to create manually a way to reuse them which is what the UITableView does.
If you want something like facebook, so that the context + comments both are movable,then go with option 2.
But, if you want content always at the top, go with option 1.
Indeed, UITableView is a subclass of UIScrollView.
And If you think you might have many comments like (50+),
If you use scrollView, then you should have to supply scrollView with those number of UIView objects.
But, if you use tableView, it perfectly reused already created views.So evenhough you have 1000+ comments, it just uses 5 UIView objects

Can I use more than one custom tableviewcell nib file in a UITableView?

I want to put different cells in a table, and all of them is kind of complexity, so I want to use nib for these cells. However, i really don't know how to use multiple cells in a table. Can you help me?
You can use as many custom UITableViewCells as you want in a single UITableView. The issue here is: What kind of logic do you want to implement? Only you can define it. You can start by using this tutorial to see how to implement the custom UITableViewCells:
http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
You can then reply to my answer to tell me what logic do you to implement. For example:
first 3 cells one with a type of UITableViewCell, then 3 with different UITableViewCell.
Alternate between cells (for instance, 4 different UITableViewCells in a row)
You need to specify what you need. :)

How to display multiple objects in a single row in my UITableVIew?

I want to display three items in my UITableView's row. What should be best and efficient way to do this.
Any suggestions?
Thanks,
Take a look at this example:
http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
It shows you how to customize many aspects of a UITableView (and cells too).

Resources