Facebook like app- cells with different size - SWIFT - ios

and sorry for my bad english.
I want to create an app like Facebook that in one tableView there are two types of cells, one for status post and other for photo post.
the issue is that photo post cell and status cell has a different size.
How can i make tableView with two cells that has a different size?
That's how I want it to look:
That's how it look:

You can adjust the cellsize depending on object you want to have inside the cell.
This tutorial is what you are looking for:
http://www.raywenderlich.com/87975/dynamic-table-view-cell-height-ios-8-swift

Another option might be to break your list items into multiple (fixed height) reusable rows.
eg:
#text post:
-Title row
-Text row
-Footer row
#image post:
-Title row
-Photo row
-Footer row
While your table source & delegate may become a bit more complex, this pattern has been proven to scale.
This article explains how facebook did it for android:
https://code.facebook.com/posts/879498888759525/fast-rendering-news-feed-on-android/

Related

expandable cells table view best practice for ios

For the iOS we are not been provided any expandable list view as a component. so to use the expandable list we are having 2 basic options:
Option-1: Table header as the main view and then clicking on it open cells under that header.
Option-2: Cell as the main view and add more cell below as if its sub cells when clicking on any of the cell.
And more than this 2 different developer uses different logic. so Can we know that which would be the best practice to use expandable/ collapsable Table view in iPhone/iPad application.
Thanks in advance. This could be consider as a knowledge sharing or better coding practice related question.
There are a million ways you could do this.
In the past I have created a custom "stretching" cell that would stretch its own size to show items that were hidden. This could be a way of doing it.
What you would need to do is have a cell that when clicked, opens up (revealing a new cell hidden underneath it). You could also have it seem as if there is another cell being shown below the clicked index, but in reality you are only adding a new cell at cell_index_clicked + 1.
Hope this helps you think it out.
Use iOS 8 auto layout ..........

Want to achieve this kind of functionality in iphone app

I am having an app in which I want my view to be loaded like shown in the screen shot below.
The following view contains page control to show multiple images,buttons,labels,resizable text view and resizable text field in a single cell of table view.
There will be number of rows in a table view and rows will be generated dynamically.
Is there any cocoa control or tool which can give me functionality like this?
I have searched on cocoa control and goggled it a lot but couldn't find any matches to achieve this.
I thought of taking different views with sub viewing it didn't get much idea of how to generate it dynamically.
Please help me if someone has achieved this kind of functionality in any of their projects.
Thanks in advance.
Hint :
Divide each items in cells for single section, that means, one section for one item.
for e.g.
User photo, User name, User location and Post time in one cell.
Image gallery in another cell with page control on it.
Favourite (liked) post, comment on post and price in individual cells.
what you've to do is, create and add each item in a cell. While you're giving the height of each cell using delegate, check for conditions for which you're assigning the height. For e.g. if you've likes for the post (favourite) then only give height for that cell otherwise pass 0 (zero). Do the same for everything or as per your requirement.
For comments, you've to calculate text height, and based on that, you'll need to set height for comment cell.
References:
Here's a nice tutorial for this (not exactly) stuff. Rebuilding Instagram Feed Table View. I also googled a lot and found this, https://www.cocoacontrols.com/controls/stxdynamictableview, you may also need https://www.cocoacontrols.com/controls/mhpagingscrollview for showing image gallery.
P.S. This is not a "lunch plate" of course you've to make it for your self. Get hands on the keyboard! :)
Good luck!

iOS - newsfeed structure: does Instagram use TableViews inside of TableCells?

I'm making newsfeed for my iOS app which is very similar to Instagram.
How does Instagram group its photos and comments in one long table? It seems most logical to me to put TableViews into TableCells of parent TableView.
So child TableView inside of TableCell will contain: username in row 1, photo in row 2, +3 last comments in remaining rows.
And it will be easy to calculate number of rows for parent table. It will be = [feeds count].
But I've read that it's bad idea to put TableView into TableCell.
So should I use one big flat table (why)? Calculating number of rows in numberOfRowsInSection will be more complicated then as well as determining what to show in cellForRowAtIndexPath...
It seems to me they're using a section for each photo, with a header view for avatar, location, date and username, and a custom footer view for each section which contains the like/comment button, as well as the comments and likes already on the post. If I were to make instagram, that's the way I would go.

Multiple columns in tableview ios

I am working on an app using objective C and Xcode.
For the moment I am using a table view and returning rows with cells containing an image thumb and title. My problem is that now i need to change the layout and for 4 of the cells I need to make them fall on the same row (so each article of the 4 should be 50% width). So basically create 2 columns but only for 4 of the articles. The rest remain on 1 column (full width).
I would add an image but I don't have enough rep points.
I know there is some thing like collection view...but I am not very familiar with that one and I was hoping maybe there's an easier way than redoing the viewcontroller and all the connections I already have created there.
Since I am already using tableview..what's the best way to change the layout to fit what I need now?
Based on what you're trying to do a UICollectionView might not be the best bet. I would create a second type of UITableViewCell for those rows with 4 columns. This should help Multiple Custom Rows UITableView?
You can use UICollectionView with flowlayout and variable cell width. There are many tutorials about it out there.
You can also try this library: https://github.com/bryceredd/RFQuiltLayout
Have you taken a look at this library:TSUIKit
If you just want to quickly arrange your data, this would be much easier than trying to wrangle with UICollectionView.

UITableViewCell- controlling movement

When editing my UITableView, I give the option to move cells to reorder the data. However, The top two cells in the table are cells that give information about all of the cells in the table, and I dont want the user to be able to move information cells into that section. Here is a picture of the problem:
The user shouldn't be able to drag the cell titled 'This is bad!!!' into the section with the 'Total:' and 'New Group...' cells. Is there a way to control this functionality? I haven't seen a delegate method that does this, but I could have missed one.
Edit: oops! I just saw that someone else has asked the same question on SO, so I'm going to post the link and close this question. Thanks #fzwo for your help.
How to limit UITableView row reordering to a section
tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath: from UITableViewDelegate is what you're looking for.
In your concrete case, you could also display the header information in the actual tableView.tableHeaderView. This scrolls like an ordinary cell, but isn't a cell. It would probably also make sense from a UI perspective, because it is something different than your ordinary cell content.

Resources