Newbee
Newbee

Reputation: 3301

How to hide empty UITableViewCells showing in UITableView with plain style - IOS?

UItableView is showing with empty rows like below...

enter image description here

how to hide it without changing the tableview style. Do I need to resize the table View, if so how can I know the height exactly to set.

Upvotes: 4

Views: 2054

Answers (5)

NuN
NuN

Reputation: 408

Just drag and drop a view from object library to the TableView empty shell in storyboard. Make the view as footer of the table view (in document outline drag it below the cell's if it is not already at below) make the height of the view '0'. You will not see the view in storyboard because its height is '0' but when its runs it will hide the cells. I think that should work.

Upvotes: 0

Sergey Zhukov
Sergey Zhukov

Reputation: 534

self.tableView.tableFooterView = [[UIView alloc] init];

Upvotes: 6

Rick
Rick

Reputation: 1818

What I had done in one of my projects was to set the tableview's background color to clearColor and separator to none.

Upvotes: 0

kirti Chavda
kirti Chavda

Reputation: 3015

you add UIview in footer of uitabeview use of xib or tableview delegate method

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;
{
 return 1;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section; 
{
 return yourview; 
}

Upvotes: 3

gasparuff
gasparuff

Reputation: 2295

Why don't you put some logic into your

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

function?

Just return the number of cells which are really filled with data

Upvotes: -1

Related Questions