Can i configure a section in UITableView to be multi-select - ios

I have a requirement in my project, i want to configure a section to be multi-select in UITableView and rest of the sections as single-select. How can i achieve this ?
Any help will be appreciated.

Upon My understanding from your question you need to delete multiple row on an action(say button taping)
You can use a checkmark per selected row by setting the accessoryType on the selected UITableViewCell instances to UITableViewCelAccessoryCheckmark.
To deselect the row, set it back to UITableViewCellAccessoryNone. Manage some NSArray for the selected row like in your table view delegate in the didSelectRowAtIndexPath:" delegate method.
or
you can enumerate which cells/rows were selected , simply iterate over the cells of the table looking for UITableViewCellAccessoryCheckmark.

You can use following sample codes:
http://www.edumobile.org/iphone/iphone-programming-tutorials/multiple-row-selection-in-iphone-table-view/
https://developer.apple.com/library/ios/samplecode/TableMultiSelect/Introduction/Intro.html

Related

How to add a subview to a TableViewCell?

I need to add a subview to TableViewCell when the button in TableViewCell is clicked it should show another tableview as a subview and height of the tableview should be dynamic according to number of cell.
How can I do this?
Above screenshot is taken from a very popular shopping app and I need to do the same in my project.
You can easily achieve this using simple UITableView. For that you need to set all your main categories as your UITableview section and respected sub-categories can be added to respective rowOfSection.
You can use just one table view with UITableViewStyleGrouped style, and set "Men","Women","Kids & Baby" as TableView sections header, keep an boolean value to determine the result of "numberOfRowsInSection:" of each section and reload tableview.
See the below link at github:
https://github.com/OliverLetterer/SLExpandableTableView
This contains the Expandable TableView, which you required. You have to implement SLExpandableTableViewDelegate and SLExpandableTableViewDatasource which contains different method, in which you have to provide inner tableview as well.
Hope this helps you.
You need to do some work on your own I can give the directions that'll give you a way from my point of view :-
Make a Custom cell which you want to expand.
While designing the cell make its height in storyboard like 200 or so according to your need and add all the elements those you want to see when the cell is expanded.
You'll need two delegate methods first -didSelectItemAtIndexPath and second HeightForRowAtIndexPath at index path.
First You need to make sure the user taps on the button or cell that you want to expand , and to achieve that you need to call didSelectItemAtIndexPath.
Once you get your cell Position, in HeightForRowAtIndexPath check the indexpath is equal to your cell's indexpath,if yes then return the exact height(ie:200) of your cell otherwise return the default(ie:70) height of you cell.
Note : In didSelectItemAtIndexPath you need to call to method to update the current cell
[self.tableView beginUpdates];
[self.tableView endUpdates];

Filter tableview based on an item in another tableview

I have a UITableView displaying comments which are dynamically displayed through JSON. On the same page, I have another UITableView as a Filter.
The filter displays a list of the types of comments. I need to filter the main tableview based on the type of comment selected from the filter tableview.
Filter TableView1 based on item selected in TableView2.
TableView1 - Main tableview
TableView2 - Filter tableview
Following is an image of the page:
For instance, if I select "Worst Moments" in TableView2, TableView1 should display only those rows that contain the comment with "Worst Moments" as a keyword in it.
Can anyone help me with a code, how to filter items in TableView1 based on an item selected in TableView2?
Can anyone help me with a code
if you are asking us to code it for you then aside from the most generous souls here, most likely not.
You are almost there. This is how I would approach the problem
What you need to do is add UISearchBar to your ViewController
When an option is selected in TableView2 make it into a string
Pass that string to UISearchBar
Use that to refresh your TableView1
If you need some help you can either google UITableView & UISearchBar or you can check this Tutorial HERE.

how to delete particular row in table view and edit that custom cell details

how to delete particular row in table view in Xcode.
when we can delete one particular row in table view.
and also edit that custom cell objects in another view
You can use deleteRowsAtIndexPaths:withRowAnimation:
You should read the UITableView documentation.
Editions are done with the UITableViewDelegate.

Updating UITableView cells according to the text entered in a text filed that is in the same main view

Is it possible to update the cells of a table according to the value entered in the text field which is in the same view or when clicking on a button which is in the same view. can this be done when all the components are in the same view? of course i know that i will have to use a cell and a table view an all in that view.
If it's possible please hint me to what method in the TableView Delegate I should work with to make this happen or if I have to write a custom method.
Thanks in advance.
You should look into UISearchController
Links to explore:
http://www.raywenderlich.com/16873/how-to-add-search-into-a-table-view
http://jduff.github.io/2010/03/01/building-a-searchview-with-uisearchbar-and-uitableview/
http://www.iphonedeveloperdiary.com/2010/07/adding-a-uisearchbar-to-top-part-tableview/
http://www.iphonedevsdk.com/forum/iphone-sdk-tutorials/38913-slicks-uitableview-series.html
https://developer.apple.com/Library/ios/documentation/UIKit/Reference/UISearchDisplayController_Class/Reference/Reference.html
OR...
If you want to do it using something like a simple UITextField, then in the -textFieldShouldReturn, you can use NSPredicate to create an array of searched objects and then simply can do a [self.tableView reloadData].
(just ensure that the datasource of your tableView is using this array)
You can do it just by using
[tableView reloadData];
On Clicking if button please ensure to update UITableView Datasource Array to update.

How to distinguish between UITableView custom section click and section first row click?

UITableView returns the same callback "didSelectRowAtIndexPath" with the same NSIndexPath (0,0) both for section click and section first row click. I'm using custom view for section header view and I need to perform some action on these section rows. Tried checking cell class with [tableView cellForRowAtIndexPath:indexPath] but it's obviously returning the same row cell instead of section cell. Any suggestions?
UPDATE I could add my custom section view to first row instead of adding it as a section, however in that case, I would need to return different row height in "heightForRowAtIndexPath" and that would be not-performanc-wise decision.
UPDATE I'v designed my section view as a subclass of UITableViewCell, because I prefer to get native UITableView callbacks instead of workaround'ing with tap gestures or buttons.
Centurion, if you want to have section that you open/close easily, I suggest you to use the class APLSectionHeaderView.
You can find more information on APLSectionHeaderView.h and APLSectionHeaderView.m
Hope it will help you.
I've been using it, so if you have some question about it...

Resources