Tool bar below table view - iphone

I need some clever hints here :)
I need to add a tool bar to my page containing a table view. If the table does not fill up the entire page I need the tool bar to be positioned at the bottom at the page but if the table is longer than the page I need the tool bar to be positioned at the end of the table.
What to do?! :/
Thanks a lot for any help,
Stine

Use the footer view of UITableViewDelegate....
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
Simply return a view from this and it will be placed at the bottom of the specified section (either a single section or your last one).
Also use..
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
To tell the Table view the height of the view.

Related

How to load a loading view at the end of table view?

I have a table view in which all are customised cells which is loading from 3 types of custom cells object classes.I have done paging also so that it will load 5 pages at the begning and then the second one like that.the problem is at the end of the table view cells i need to add a loading view.For that i used - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)sectionand added an activity indicator and loading label.but its position is not getting correctly.some times if the contents are more its position is not going correctly.Can anybody guide me the correct approach in achieving this?
You say : "loading view at the end of table view" whereas this function :
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
Will add a view at the end of a section that is different from what you want to do.
I suggest you to have a look at the following UITableView property :
tableFooterView
(documentation)

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).

Custom View in UITableViewCell

I am trying to create a UITableView Section that contains two buttons aligned horizontally. This would be similar to the Contacts app, where on the bottom of a specific contact page they have buttons lined up to Text the contact and share the contact. However in my tableView, I want the two buttons to be placed in between other sections - so i can't set the table's header or footer view? How would i do this?
If I understand the question correct, you want something like this
section 1
your buttons
section 2
For this you can create custom headers/footers for sections instead of table. The methods you might be looking for are in UITableViewDelegate
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
Look into subclassing UITableviewCell class, you can draw your custom view in there and use it, look at the UICatalog sample project in Apple site they do that there a lot