Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement UITableViewCell without UITableView

I want to use the power of UITableViewCell like disclosure accessory, but I don't need the whole UITableView. Is this possible and appropriate to do so ? I don't see any delegate on UITableViewCell, so don't know where should I put code previously in - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath; any references or suggestions on this ?

like image 426
sarunw Avatar asked Jul 02 '11 05:07

sarunw


People also ask

How do I populate UITableView?

There are two main base ways to populate a tableview. The more popular is through Interface Building, using a prototype cell UI object. The other is strictly through code when you don't need a prototype cell from Interface Builder.

How can we use a reusable cell in UITableView?

For performance reasons, a table view's data source should generally reuse UITableViewCell objects when it assigns cells to rows in its tableView(_:cellForRowAt:) method. A table view maintains a queue or list of UITableViewCell objects that the data source has marked for reuse.


2 Answers

Correct me if im wrong but .. Why would you use a cell like that ? If you dont want to use the power of the UITableView you can just add a view and do all the stuff you do in your cell. And that would keep the Apple Standard too.

like image 75
Xabier Arrabal Avatar answered Oct 02 '22 23:10

Xabier Arrabal


You could just make a UITableView with one section and one row, and load that cell into it. This would be pretty easy to do and wouldn't run the risk of running afoul of the Apple review board.

like image 42
PengOne Avatar answered Oct 03 '22 01:10

PengOne