user1282637
user1282637

Reputation: 1867

Forcing footer to stay under last cell in tableview

I have a tableview with custom cells. What I want is to have a footer (like a "loading" indicator") at the bottom of the tableview. I am using this code to add the footer:

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    [spinner startAnimating];
    spinner.frame = CGRectMake(0, 0, 320, 44);

    return spinner;
}

But this makes the footer "float" over the bottom of the tableview and overlaps the bottom of the table:

enter image description here

How can I force the footer to only be visible under the last cell of the table? Like this:

enter image description here

Thanks!

Upvotes: 0

Views: 1205

Answers (2)

Alan Lee
Alan Lee

Reputation: 81

You can do it in the storyboard by dragging a UIView into UITableView, and place your loading indicator there . From your document outline should looks similar to this enter image description here

Upvotes: 0

Joe Smith
Joe Smith

Reputation: 1920

I think you should set tableFooterView instead of setting section footer views.

Upvotes: 1

Related Questions