How to add dynamic touchable objects to a TableView cell?

时间:2015-07-31 19:51:21

标签: ios xcode uitableview uicollectionview

I am looking for a way to add different objects (40x40) to a cell so that if you touch one of these objects it will go to another screen. The only problem with this is I don't know the best way to do this as I want the table view is dynamic and i want it to change its height as more objects become available.

I think these are my options right now. Either make a collection view or somehow make it so that the table view cell is 40 x 40 and have 8 or 10 table view cells in a row depending on the phone before it starts the next row and populates that.

An example of what I am thinking is Instagrams discover page or in the new snapchat update the circles that are on the main page. Does anybody know the best way to go about this, or would a collectionView without a table be the best way to do this?

1 个答案:

答案 0 :(得分:0)

How about self sizing cells in UITableView?

tableView.estimatedRowHeight = 44
tableView.rowHeight = UITableViewAutomaticDimension

If you setup your constraints correctly the cell will size itself depending on the size of the content.