I iOS 5 Apple added functionality to make it easier to make a multiple selection table view through:
self.tableView.allowsMultipleSelectionDuringEditing = YES;
When the table is in edit mode I can see the multiple selection mark but when I check it, it does not display the usual red checkmark to denote it is selected. So I assume I have to programatically access that UIView and set the appropriate image.
So my question is, how can I access the UIView that displays the circle that represents if the cell is selected or not?
(source: winddisk.com)
There is no need to programatically access the UIView and update it with the checkmark.
The solution to the problem was way easier, here it is:
Cells not getting selected in UITableView with allowsMultipleSelectionDuringEditing set in edit mode
Related
I don't want to show check marks when user select multiple rows in table view. I also want bit smaller selection indicator view with different color.
I am enabling this selection style by setting editing mode
[self.tableView setEditing:YES animated:YES];
Is there any way to set custom view/style for this type of selection?
I am very sure that there is no api allowing you to specify a custom view for any of the editing controls that appear on the left (the delete control, insertion control, or either version of the selection control).
But you can achieve this another way. At a high level it would be like this:
Don't set editing on the table view.
Do set allowsMultipleSelection instead of allowsMultipleSelectionWhenEditing.
If you are using the built-in Edit button change it to your own Edit button with an action that sets a flag like isInCustomEditMode. The action will also need to toggle between the Edit and Cancel button.
In cellForRowAtIndexPath: check that flag. If set then display the cell with your own view control.
In the didSelect... and didDeselect... methods set your custom view to match the state of the cell.
If your designer allows it you could also consider not displaying the selection control at all. I would argue that the highlighting in the cell when it is selected is indication enough to the user that the cell is indeed selected.
I thing you have below two lines in your code,Remove these below two lines
table.allowsMultipleSelectionDuringEditing = YES;
[table setEditing:YES animated:NO];
Instead,You want Multiple selection
table.allowsMultipleSelection = YES;
Its not displaying the selection control.
Is it possible to customize the multiselect edit mode? So instead of the default selection icon (the circle with the checkmark), I need to show a custom one, with selected and unselected states.
I also need to indent the cell more to the right.
Obviously I would like to use as much as possible of the system provided animations.
HEre's a screenshot of the sample editing mode of uitableview. (My cell is much more complicated :)
Thanks,
Jason
You can customise the cell.. create a UITableViewCell with a UIButton and set the custom images you want for the selected and default states and load this custom cell in cellForRowAtIndexPath:
iOS Proficiency: Beginner
If I have a Xib with multiple fields that all need their own Picker View, what's an appropriate/canonical way to add multiple picker views on the page without getting the Design View all cluttered up?
1) Only add the PickerView programmatically and not via the XIB?
2) Use only 1 Picker object and populate it with different values based on the field
selection? (Possible memory benefits?)
3) Place the UIPickers on the View with a tiny height/width and then programmatically adjust height when necessary? Not even sure if the height is adjustable.
4)Combination of some of the above?
You can see in the image below, how cluttered it looks already even with just one picker view:
The view that you have with the text fields and picker views would lend itself to be part of a UITableView.
See the calendar app when you add an event.
You can set this up fairly easily by using a static UITableView.
I'm replying on my phone at the moment but will look for a tutorial if you would like.
If only one pickerView will be visible at once, then you should consider using only one pickerView and configure it's delegate/datasource so that you can give it a different datasource for each field.
Unless more than one is visible at once, there really isn't any reason to use more than one in your nib file. And even if you used more than one, you would still have to configure you delegate/datasource methods to handle each individual picker.
Hope that helps.
EDIT: It would be a little bit of work, but if you wanted the pickerView to animate in and out of the view whenever you need and if you wanted to clean your Xib up even more you could do the following:
Create a subview containing your pickerView
Set up a protocol on the subview to allow you to pass the selected value back to the view controller.
Set up your viewController to conform to the protocol on your picker subview.
Set the pickerView to be each textField's inputView.
Set the textField's delegate methods to configure the dataSource of your subview when editing begins.
By doing this, you have set your textField so that when it receives firstResponder that it will display the pickerView instead of a keyboard.
My app design required a page that display 'user information' and i currently have this setup using a simple table view in a View controller. Now, the tricky thing is I need to be able to provide functionality to the user to be able to edit these on the same same screen. So essentially when the user taps on a row in the table view, I want that little flashing text line at the end of the current text in the row so the user can edit what's currently present and I also want a save button to apear on the top when a user has started editing. The tricky part is, not all fields in my table view will be editable. So, I need certain fields to be editable and have the save button appear and certain fields not.
Can you tell me how would I go about modifying my existing design to implement this functionality? I would appreciate some code if you think you can show me how exactly I would go about doing things.
You would probably want to make some custom UITableViewCells. You can fill a tableview with all sorts of different cells which are different sizes and looks different, all at the same time. I would suggest a custom UITableViewCell which will hold a UITextField as one of the subviews. On the cells which you don't want user interaction with the textfield, either make a new custom cell that uses a UILabel or just do textfield.userInteractionEnabled = NO. Look up some custom uitableviewCell tutorials to get you started and then use the approach that I suggested for your problem.
I am trying to duplicate the functionality found in the Settings app when managing the Spotlight search options:
I need to be able to rearrange the order of a tableview without an editButton and will need to be able to select/deselect a cell, having the checkmark appear to the left of the cell label.
When I use the following code:
-(UITableViewCellEditingStyle)tableView:(UITableView*)tableView editingStyleForRowAtIndexPath:(NSIndexPath*)indexPath {
return 3;
}
I get this:
This works, but I was wondering if there was any way I could customize the editing style so that the checkmarks are more like they are in the spotlight settings (The red checkmarks look like items are being selected for deletion).
Possible duplicate of: How can i custom UITableViewCell editing style?, but no one seems to have answered it.
Set the editing style to UITableViewCellEditingStyleNone. Instead, create a checkmark image and a "blank" image (the same size at the checkmark image) and use these to set the cell's imageView.image property. You will need to keep track of which cells are checked or not. Toggle this state and the image view from the didSelectRowAtIndexPath method.