Saturday, June 8, 2013

UITableViewDataSource tableView titleForFooterInSection example in Objective C (iOS).


UITableViewDataSource tableView titleForFooterInSection

Asks the data source for the title of the footer of the specified section of the table view.

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section

Parameters of [UITableViewDataSource tableView titleForFooterInSection]
tableView
The table-view object asking for the title.
section
An index number identifying a section of tableView .

Return Value
A string to use as the title of the section footer. If you return nil , the section will have no title.

Discussion of [UITableViewDataSource tableView titleForFooterInSection]
The table view uses a fixed font style for section footer titles. If you want a different font style, return a custom view (for example, a UILabel object) in the delegate method tableView:viewForFooterInSection: instead.

UITableViewDataSource tableView titleForFooterInSection example.
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
    if (section < self.practiceLessonSet.lessons.count) {
        if ([[self.practiceLessonSet.lessons objectAtIndex:section] words].count == 1) {
            return @"No replies yet. Try the share button?";
        }
    }
    return nil;
}

Example of [UITableViewDataSource tableView titleForFooterInSection].
- (NSString *)tableView:(UITableView *)tv titleForFooterInSection:(NSInteger)section
{
    if (section == 3)
        return @"SOME TEXT FOR SECTION 3";
    else
        return @"";
}

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

    return nil;
}

End of UITableViewDataSource tableView titleForFooterInSection example article.