Can I add buttons to sections of grouped tableView? - iphone

I have a grouped tableView with 5 sections and i want to add buttons per sections.
For example i have add (+) button in all sections near the section title.
Can i do that?
Regards,
ZaldzBugz

You can implement tableView:viewForHeaderInSection: method in table's delegate and create custom view for section header there with title and button (and with whatever else you need).

Related

Hide rows of a section in a tableview on tap

What is the best way to show and hide rows related to a section on tap?
I have a table view with multiple sections and populated with data
I want to hide the rows when the user press on the section
What is the best practice to achieve that?
Here is maybe the answer to your question. (you can expand and collapse the height of a cell)
Swift: How to animate the rowHeight of a UITableView?

multiple column menu in iPhone

I want to create a menu like below for my iPhone app. Is it possible?
First, only the main items will display. and when we clicking on a main item its sub items will show in two columns.
The easiest way to do it is using a customized UITableView with sections.
Each header of each section will correspond to your "Main Item X". You can use a custom view for your headers thanks to the UITableViewDelegate methods, so you can provide a UIView containing a UILabel and the image of your ">" or "v", and a UITapGestureRecognizer to handle the tap that will open of close the submenus
Each section will contain either 0 (if the menu is closed) or N items (if it is open)
Each cell of your tableView, that will correspond to a row, will contain two labels (or buttons), one for the item on the left and one for the item on the right.
When the UITagGestureRecognizer of a section is tapped, you can toggle a BOOL that tells if the section is "open" or "closed" and then call reloadData on your UITableView to show or hide the corresponding cells
The rest is basic table view programming so you can implement the table view as you usually do (see the "Table View Programming Guide" in the Apple doc for more details).

What is footer in table view IOS

What is footer. When we will use that. I have a sample code in which they used method viewForFooterInSection. What it will do... Any idea?
It is used as a view at the end of the section, placed after the cells in the section, and before the header view of the next section.
Here is the appropriate docs link and a photo from that page:
A UITableView can be considered as made of three main elements, a "list" - containing sections and cells, a header and a footer.
The list area can contain from 1 to many sections and in a grouped table view you may also have headers and footers for sections. Assuming you are talking about table footers and not section footers the following is my answer:
The table's footer is what it says on the tin... you might want to use it to display some additional information about the data of the table view.
Check the App Store, Apple display some information about the user who is logged into the store at the bottom of the table view (in some areas).
I sometimes use this footer view as an area to display a UIActivityIndicatorView, and initiate a kind of "fetch more" feature for any API related data.
The UITableViewDelegate protocol allows you to return views for the header and footer of a section. Simply implement this method and return a UILabel filled with the text you want to display.
In viewForFooterInSection you can add customized labels or other objects to display in footer section.
From the below two links you can batter understand.
Update section footer title in UITableView without reloading
Setting a basic footer to a UITableView

UITableView like Contact App

I try to create an UITableView similar to the Standard Contact App, when selecting a contact (i.e. grouped style). But how do I get some controls at the top or at the bottom of the cells, which scroll with the rest? In the Contact App you have at the top the picture together with the name and at the bottom three buttons. Are these just special customized Cells? Or can you have controls directly there?
Thanks for your help!
Regards
Matthias
I played with table header/footer views. You can create them in IB and assign them to
self.table.tableHeaderView = yourHeaderView;
self.table.tableFooterView = yourFooterView;
Needless to say, that you customize them as your wish.
Another option is to customize a table cell view for the section 0 if you have a grouped style table. You can add there a picture and a button, whatever you want.
In both cases all your elements will scroll with the table view.
Is that what you asked for?
When I did this functionality, I used a combination of UIViews and UITableViewCell.
As a header I inserted UIView, and it placed the UIButton (with picture) and UITableViewCell. After laying a transparent UIView and subscribe to UIControlEventTouchUpInside, which highlight the cell ([self.tableHeaderCell setHighlighted:YES];)

When and where should I add a view to a UITableView's footer?

I am populating a UITableViewController's UITableView through code only. At the bottom of the table I wish to position a button that scrolls into view as the user scrolls to the bottom of the table.
When in the UITableViewController life cycle should I populate the table footer with a button? viewDidLoad?
p.s. I wish to avoid using section footers in the UITableView.
Yes, viewDidLoad is the correct place. It's not a stone-set rule though - I have change footer view in many different situations, such as after rotation in didRotateFromInterfaceOrientation.
Note that the view will be repositioned to location immediately below the last row, so if you want to provide a margin or centering for your button I suggest adding a plan UIVIew as footer, and then add your button(s) into that UIView.
Yes, put it in viewDidLoad. Here is some sample code.
You can just set the tableFooterView property of a UITableView to your button.