Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text under a UITableView cell

The iPhone's settings application is build around a UITableview. In some views there are additional texts between cells. For example in "Settings" -> "General" -> "Network" there is the text "Using 3G loads data faster, but may descrease battery life" under a cell with an UISwitch. Any ideas how to implement this?

Images of what I mean can be found here:

http://www.tipb.com/2008/07/12/how-to-disable-3g-on-the-iphone-3g-for-more-talk-but-less-speed/

like image 979
user467225 Avatar asked Nov 22 '25 09:11

user467225


1 Answers

If you have a grouped table view, the tableView:titleForFooterInSection: method found in the UITableViewDataSource protocol and the UITableViewController class handles this for you:

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
    if (section == 0) {
        return @"Footer text for first section, goes below cells in that group.";
    }

    return nil;
}

To place that text between cells, you have to have multiple sections and tell your tableView:cellForRowAtIndexPath: method to place cells that you want beneath that text in the next section.

like image 157
BoltClock Avatar answered Nov 24 '25 23:11

BoltClock



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!