Setting a basic footer to a UITableView - iphone

How is a basic footer set to a UITableView programmatically?
Just a centered text?
EDIT:
How can the bar color be set and the footer bar position fixed to the bottom of the screen or if the thumbs dont fill a screen, the footer isnt above the bottom of the screen.

viewForFooterInSection sets the section's footer. To set the table's footer, you want to set
self.tableView.tableFooterView = myCustomFooterView
where myCustomFooterView is something you setup elsewhere. You'd probably set that in viewDidLoad.

You can use UITableViewDataSource callback (just text):
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
Or UITableViewDelegate (any custom view you like):
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

Related

Custom Section Title View for UITableView

In some apps such as Cool Iris, LiveShare, i see them using custom views for their plain UITableView section titles. Is there a way to replace the standard section title bar with a custom view?
In order to customize the look of your section header, there are two methods you will probably want to use.
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
and
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
These are both found in the UITableView delegate protocol. The first will let you create a custom view to display as your section header. The second just makes sure you get the size you want for it so that your view doesn't get cut off

Displaying both section header and custom view for table section header

I have a table view with multiple sections. I want to display different section header titles and want to add a label on the right corner of each section at a right margin of 4px.
Can I implement both
- (NSString *)tableView:(UITableView *)iTableView titleForHeaderInSection:(NSInteger)iSection
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
to achieve this?
Only one of them will ever get called successfully. tableView:viewForHeaderInSection: will get precedence.
Define a view with a title label and another label that sits on the right corner and return it in tableView:viewForHeaderInSection: with the values set.

How to ensure Search bar sticks to the top in iPhone SDK?

I have a table view along with search bar.
I want to ensure that while scrolling the tableview, the searchbar stays on top - always.
How can this be achieved?
I suggest you to Keep both of them separated.
You have to return your search bar in the table's delegate callback
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
Note: don't forget to implement tableView:heightForHeaderInSection:

UITableView Header View Scrolls

I am using a header view, not section header, with my UITableView. The documentation says that the header view sits on top of the table, but my header view scrolls just like a normal row. Is there a way to make the header view always visible at the top of the table?
You certainly did found the solution for this, but I'm posting it here for other people.
The table view header and footer views do scroll with the rest of the rows.
If you want them to have a fixed position on top, or bottom of the table view then you don't really need a header or footer view.
Just add your desired view as a sibling of the table view (subview of tableView's superView) and position it on top or bottom of the tableView.
The solution is to implement:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
and
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
for a fixed header view, not use the self.tableView.tableHeaderView (this one is scrollable).

UITableView Implementation

in the screen shot below, there are UISegmentedControl in between grouped UITableViewCells...it seems. How does one add other controls in between grouped cells in a UITableView?
You could make the Segmented View the same size as 1 table cell. Dead Simple to do in Interface Builder.
Tables with multiple sections, and sections can have custom header and footer..
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section; // custom view for header. will be adjusted to default or specified header height
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section; // custom view for footer. will be adjusted to default