Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView - How to show rows only which contains data

How can i show UITableView Rows only which contains data not the other rows. By default UITableView shows 10 rows. If we have data for three rows It will display three rows only How can I implement this? Thank you.

like image 297
nitesh meshram Avatar asked Jun 20 '11 11:06

nitesh meshram


People also ask

How do you get the indexPath row when a button in a cell is tapped?

add an 'indexPath` property to the custom table cell. initialize it in cellForRowAtIndexPath. move the tap handler from the view controller to the cell implementation. use the delegation pattern to notify the view controller about the tap event, passing the index path.

What is table View delegate?

Methods for managing selections, configuring section headers and footers, deleting and reordering cells, and performing other actions in a table view.

How do you deselect a row in Swift?

deselectRow(at:animated:) Deselects a row that an index path identifies, with an option to animate the deselection.


2 Answers

You can set a footer view and make it invisible if you want. Separators will appear only for rows which contain data:

self.theTableView.tableFooterView = [[[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 10.0f)] autorelease];
like image 118
Dimitris Avatar answered Oct 13 '22 00:10

Dimitris


Try this ..

self.tableView.tableFooterView = [UIView new];
like image 24
iosLearner Avatar answered Oct 13 '22 01:10

iosLearner