UItableView custom cell with a plus button on the left side (outside table view) - iphone

I want to add a plus button outside my table view cell (on the left side), but the button should get scrolled if I am scrolling the table. Does anyone has a solution for this??? Also, there are 8 different sections in my table. There is no need to show that plus button for the first 7 sections, but there is a plus button in the 8th section clicking on which will increase the number of sections by 1. (the catch here is that the plus button is NOT INSIDE THE CELL and there are different sections where we will not show the plus button, so no UNIFORMITY).

I belive that the best solution to this is to create a custom section header (or footer) view and put the button there. It will "look" like it's outside the table, but it will be inside the given view.
In your case, only inside the section header/footer of section 7.
That button will scrool along with the table, as the section header/footer will.
Or, alternatively, you could have an "empty" section 8 (with no rows, but with a header) and display the button there. If you want the button displayed, you should return the number of section as "8", if you want the button hidden, return section count as "7".

Related

How can create collapse tableviewcell & every row contain plus button in every row in tableview?

I have tableview every row contain plus button must when press on button add below row can remove this row by button and more detail in below screenshot this image contain ui must to do in app

Swift: UITableView scrolls back to top when section header height is changed dynamically

!
I have a tableView with a single section. The header of this section holds the Sort By label and the three ImageViews. The view below it is a UITableViewCell.
The first image shows the initial view of the section header. When the header is clicked (have added a tap gesture), I expand the section view by changing the constant of the height constraint programmatically (have created an outlet for the height constraint).
Everything works fine, the section header expands as desired. However the tableviewcell scrolls right to the top again. Meaning, if when the section header was not expanded and I had scrolled down to some level, as soon as the header view expands, the entire offset is lost and tableviewcell scrolls right back to the top. I do not want this. I want the table view cell to remain where it is and for the section header to expand and collapse over it. How can I achieve this? Please help.
it sounds like you might be doing this:
setContentOffset(CGPointZero, animated: true)
which you shouldn't do.

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

Any way to make table view section title line fixed

As shown in pic, when trying slide table up, section title B line will move up as well, but will keep on top of screen until next section title line arrive to top of screen.
Is there anyway to let the section title line move as normal table cell, don't stay on the top of screen until next section title line arrived?
I dont know of how you would do this using the normal sections, you could fake it by adding extra cells to the table view which represent section headers though
There's an answer for this already here:
Change Default Scrolling Behavior of UITableView Section Header
Basically, use grouped style for the table and then provide your own UIViews for the table headers and cells to customise the look of them.

Hide some UITableViewCells when editing?

Background
I'm really struggling to work out how to handle editing mode of a UITableView and hide some rows in when editing commences.
I'm using a grouped table view style with multiple sections and multiple rows per section. The last row of each section is titled "Add new...".
The idea is to allow the end user to click the "Add new..." row within each section and then be taken to a new screen where they fill in some fields and then are returned to that tableview with their new row added within the relevant section. So the last row does not really relate to the datasource and is more of a UX thing.
I've managed to get the Add row appended to the end of each section.
The problem
I have a button that calls: tableView setEditing:animated: and this insets all the rows and adds a delete icon to the left of each row.
What I don't want to do is allow the user to delete the "Add new..." row. So my orignal thinking was to just remove the delete capability for those "Add new..." rows using the tableView:canEditRowAtIndexPath:.
This worked but looks really crap as all the rows are inset apart from the "Add new..." rows.
So my current thinking is when edit mode commences just remove the "Add" rows from the table view and then when editing mode finishes add them back again.
I tried to do this by traversing all the rows when the user clicked the edit button but it seems you can only get rows that are currently visible using cellForRowAtIndexPath:.
So I can remove the ones that are visible but as soon as the user scrolls down the tableview the add buttons are still there for the sections that were not visible (at the time editing was initialised).
Help!
Does anyone know how I can just hide the "Add" rows from each section when the user edits the table and then add them back after?
I'm looking for the same functionality that the contacts app uses when the user edits a contact.
Actually you did already close the answer, just use the method cellForRowAtIndexPath to pick up the cell you want to hide, and set its hidden property to YES. You make it!
Oh, I am sorry that I had not noticed you are using the group style, so my suggestion is that you can try to separate the add button to the others, like include it in a single section.
You can display a green (+) button on the "Add line" row so it lines up with the deletable rows.
Simply override -tableView:editingStyleForRowAtIndexPath: in your table view delegate and return UITableViewCellEditingStyleInsert for that row.
What about removing the Add line(s) from the actual data source and just calling [tableView reloadData] then when edit mode changes back, add them back into the data source and reloadData again.
return YES from canEditCellAtIndexPath for every cell in the section then in override
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {} and return UITableViewCellEditingStyleNone for the "add line" row else return UITableViewCellEditingStyleDelete