Question

On iOS 5

I Have a UITableViewController set to Static Cells. I only need 3 rows which will be filled with content for each row. So I put 3 UITableViewCell. All works fine but when I run the app, it always shows more than 3 rows. The rest of the rows is empty rows. How can I only display the 3 rows I intended to display.

Should I use Grouped style and custom the look?

Was it helpful?

Solution

set footerView to an empty view.

self.tableView.tableFooterView = [UIView new].

this works on dynamic cells. should work on static cells too.

OTHER TIPS

implement these two methods in your UITableViewController:

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    if (section == tableView.numberOfSections - 1) {
        return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];
    }
    return nil;
}


- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if (section == tableView.numberOfSections - 1) {
        return 1;
    }
    return 0;
}

In fact, these codes are telling tableview that you don't need to render the seperator line for me anymore, so that it looks the empty cells won't be displayed(in fact , the empty cell can not be selected too)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top