UITableView Footer, Stop from floating over content

IosUitableviewUikit

Ios Problem Overview


I would like to make my UITableView Footer stop floating over my content, as is the default activity. I want my footer to be.. well.. a footer. Always the last view to be displayed at the end of my tableview. :)

Same thing with the header too actually.

Is there any easy way to disable it from floating over top of the table view as you scroll?

Thank you everyone, I couldn't find an answer elsewhere.

Ios Solutions


Solution 1 - Ios

Ok, it turns out that if you set the footer view via blahblahtableView.tableFooterView = someview; , the footer will not scroll with the table.

However, if you create your footer using viewForFooterInSection, it WILL follow your view around and stick on the bottom of the screen.

Not sure why I couldn't find this answer sooner. Sorry all :)

Solution 2 - Ios

- (id)init {
    self = [self initWithStyle:UITableViewStyleGrouped]; //Default is UITableViewStylePlain
    return self;
}

Solution 3 - Ios

You have 2 types of footer: one is the section footer and the other is the tableview footer.

The section footer appears below of each section. On the other side, the tableview footer appears just once at the end of the tableview.

There is no 1-click way to disable the floating of the section footer.

If you want a "footer" that always appears as the last cell of its section and does get fixed on the bottom of the tableview you need to add an extra cell to your section and always treat it as the last one of your section.

If you just have 1 section in your tableview, you could use the tableview footer to be your footer.

Solution 4 - Ios

If you have your cells divided into sections and are using the function:

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView?

to set your footer, then in IB you could also set the UITableView Style to Grouped is another possible solution!

Solution 5 - Ios

self.YOUR_TABLE_VIEW.tableFooterView = YOUR_FOOTER_VIEW;

Solution 6 - Ios

If I got the question right, you basically want to fix the footer/header in place and scroll everything else? If so you could just have the header and the footer as separate views from the tableview, that rest above the tableview in the view hierarchy, so they cover the contents of the tableview.

If you want them to bounce (when scrolling above or below the contents) with the tableview, then you need to track the tableview's method (tableview is a subclass of scrollview, so it works) - (void)scrollViewDidScroll: and calculate the new position to either the footer or the header in there.

I hope you get my answer, I have done something similar to this and it worked (I wanted the "Release to update" kind of thingy on top of the tableview)

Solution 7 - Ios

I was having a similar problem. I was using only a footer to indicate the number of cell in the table at the bottom of it. But it was not scrolling with the table cels as i expected (its was visible at all times on top of the table until i reach the bottom where it bounces off).

My solution to overcome this was to create 2 sections, one contains the table cells and another empty BUT with a header. This header will show the counter and will behave as i wanted (to remain at the bottom of the table at all times rather than overlaying the cells).

The recommended solution of adding a dummy cell at the bottom was not useful in my case at it would be bordered with the table wired-border and i did not want that.

Hope this helps

Solution 8 - Ios

#pragma mark -- There are two options to do so --

>1. Use UITableView delegate

> effect: Floating footer on a table view

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

> 2. Use setter of table view

> effect: Attached at the bottom of last cell

theTableView.tableFooterView = YOURFOOTERVIEW

// Do not set this delegate
// or you would get a extra blank at the bottom of the table

//  -(CGFloat)tableView:(UITableView *)tableView
//  heightForFooterInSection:(NSInteger)section{
//	  return HEIGHT;
//  }

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJasonView Question on Stackoverflow
Solution 1 - IosJasonView Answer on Stackoverflow
Solution 2 - IosguogangjView Answer on Stackoverflow
Solution 3 - IosrscView Answer on Stackoverflow
Solution 4 - Iosmegu5202View Answer on Stackoverflow
Solution 5 - IosZulqarnain MustafaView Answer on Stackoverflow
Solution 6 - IosHenri NormakView Answer on Stackoverflow
Solution 7 - IosAbolfoooudView Answer on Stackoverflow
Solution 8 - IosExile3daimeView Answer on Stackoverflow