Prompting user for multiple selections in an iphone app - iphone

I'm currently looking for a way to provide the user with being able to select multiple items from a collection of values.
I know this is done in the mail app whereby you can go into the edit mode of a folder and select multiple items by clicking on the circle on the left hand side.
What I'm unsure about is how this is achievable. Is anyone familiar with how to reproduce such functionality?
Thanks,
Matt Delves

The easiest way is this:
Provide a UITableView with all values the user can select.
Keep a mutable array with one object (e.g. an NSNumber) per table row to store each row's selection state.
In tableView:didSelectRowAtIndexPath:, toggle the selection state in your array for the tapped row and set the tapped cell's accessory type to checkmark or none, depending on the selection state.

Related

Different menu items for each row on a table

I have a table on a WKInterfaceController. I'd like to have a set of menu items (WKInterfaceMenu) when the user force-touches on some of the rows, and a different set of items for the other rows. Also, I want to make it so that when the user force-touches on a row and then selects a menu item, I can trigger an action that is specific to the row and menu item selected by the user. Is this possible?
Force Touch menus and other elements of watchOS are currently completely separated, so there isn't a possibility to realize such a thing. Also, Force Touch is not able to locate the position of the touch yet, it only says that the screen was force touched.
Take a cup of coffee, wait one or two years and then you will be able to do it for sure.

iPhone SDK: How to detect a row-hit while in the editing mode?

I've looked everywhere and I can't find it.
I have a UITableView that contain rows of "checkmark" cells.
The user clicks on a row to check/uncheck it.
(It works!!!!)
But I also want to allow the user to EDIT the data on that row.
... so I have an "EDIT" button at the top. The user hits it and is allowed to DELETE any
rows. (That works too!!!!)
But how do I also detect a "tap" on that row.
Where is there some kind of a didSelectRowAtIndexPathWhileInEditMode ????
(Is that really the best way to do this: Allow "selections", and "deletions", and "editing" of each row?)
You should switch on allowsSelectionDuringEditing for UITableView from code or Interface Builder

iPhone checklist app

I am trying to create a simple app that displays a list of items with check boxes next to each item, then give the user to simply check each box. Nothing (aside from the checkbox image switching) needs to happen when the check box is touched.
Each checklist is a seperate NSDictionary contained in a single master NSDictionary. The checklist dictionary contains arrays for different sections of each checklist.
At the top of the view, the user selects which set (dictionary) of checklists they want to open then I want that checklist to display underneath the picker once a "select checklist" button is pressed.
Any ideas on the best way to get this done?
The easiest thing is to use a UITableView with the accessoryType set to UITableViewCellAccessoryCheckmark for the marked cells. You can find lots of tutorials on working with UITableViews, and it'll be very simple to do what you're describing. For changing the data set, a UISegmentedControl is probably the way to go (if you weren't planning on using that already).

How to save reordered rows only on pressing the Done button?

if i reorder rows on my table view, is it possible to save the result only if the user pressed the "Done" Button?
(Reorder is working great, but i only want to commit the final result of the positions if the user pressed the Done Button, and not every time a row is moved.)
Is there something like editingStyle == UITableViewCellEditingCellMove in commitEditingStyle?
Or is this only possible in the moveRowAtIndexPath action?
Thanks for help!
You will need to create some "editing" version of your internal data structure that you commit when the user finished editing. UITableView does not keep track of where the cells are; it relies on you to do that. It just tells you when the user asks to move things. If you don't really want to move them at that point, then you'll need to keep track of where they really are versus the current order in the TableView.
Remember, UITableViews are intentionally dumb. They don't keep track of data. They just draw things. You keep track of data (as the data source), and tell them what to draw when they ask.
I generally recommend that developers separate their actual data into a separate model class, and have the UITableView maintain a separate NSMutableArray based on that model class. In that case, during editing, you would update the UITableView's array, and when finished editing, it would send that array to the model to update the "real" data.

UITableView form

I am having very annoying issue. I have one form page with 5 custom cells. Each of them has one text field. On the bottom I have one button. In an onclick button function I am gathering values from each of the 5 described text fields.
My problem is that if my keyboard is up, I will get the values of not all but just visible text fields, the ones I don't see are null.
How to override this?
Thx,
Mladen
Separate data you have from your interface, that is store your textfield values in some other place right after you finish input. And access your data there.
UI elements are not intended to store data, but just to display it and allow input - as you can see in your case if you do not see a particular element you cannot be sure that it actually exists.
This might solve your problem..
1. Register your viewcontroller for KeboardNotifications
2.When keyboard will appear resize the view so that all fields will be visible.
3. When keboard will disappear just resize it back and continue..