when I use edit mode in my tableView,I found there is a round check mark on the left.but i don't want it.how can i delete it?
My editingStyleForRowAtIndexPath is UITableViewCellEditingStyleNone
self.tableView.editing = YES;
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
return UITableViewCellEditingStyleNone;
}
i already uncheck the "Show Selection on Touch" in xib.
and i check the "Multiple Selection During Editing"
It's a result of having tableView.allowsMultipleSelectionDuringEditing = true, which has to be false (or uncheck multiple selection during editing). If you do want to have multiple-row selection enabled without the checkmark, you may have to set cell.accessoryView to something like an empty image. To change the color of the checkmark, you set the cell's tintColor.
settableView.allowsMultipleSelectionDuringEditing = NO
If you dont want that round shape checkmark you can do programatically by selecting multiple rows in tableview. Simply follow below codes :
Result :
I hope you got output as you want. if you still facing any problem let me know.
Related
I have a UITableView where the selectionStyle is set to UITableViewCellSelectionStyleNone because I don't want any visible change when a cell is tapped, but when it is in editing mode I do want the the cell selectable so the checkmark appears for each selected row, but using UITableViewCellSelectionStyleNone seems to keep the checkmark from appearing.
Any ideas how I can accomplish this?
Thanks...
Have you tried setting the selection properties of your tableView like this:
tableView.allowsMultipleSelection = NO;
tableView.allowsMultipleSelectionDuringEditing = YES;
tableView.allowsSelection = NO;
tableView.allowsSelectionDuringEditing YES;
If you want more fine-grain control over when selection is allowed you can override - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath in your UITableView delegate. The documentation states:
Return Value
An index-path object that confirms or alters the selected row. Return an NSIndexPath object other than indexPath if you want another cell to be selected. Return nil if you don't want the row selected.
You can have this method return nil in cases where you don't want the selection to happen.
we have a table view, with the cell selected being marked by a blue checkmark. The problem is that initially when the table loads, the selected cell will have the check mark in blue color which is what we need like in the below figure
Now when we select another row, the selected row check mark changes to white, what could be causing this issue?
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
Add this if in Bellow UITableView Delegate Method Before return Cell;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
}
Hope it Help's you
When you select another row, you may deselect the previous row programmaticaly by using
-(void) deselectRowAtIndexPath method of your table
Just set the tint color of tableview as you need.
I have a tableview, where when the user selects the cell it will set the accessorytype to UITableViewCellAccessoryCheckmark.
Now when I navigate to the previous screen, then go forward to this tableview, my cells remains checked.
Is there a way to uncheck all of them? I guess basically set all of them to UITableViewCellAccessoryNone.
I tried using reloadData, when the view appear, but that doesn't seem to trigger the cellForRowAtIndexPath (this is where my logic is to set the accessorytype of the cells)
I think this may do what you want. I assume you want to uncheck all the cells as part of responding to tableView:didSelectRowAtIndexPath: but you could insert this code anywhere:
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Uncheck any visible, checked cells.
NSArray *visibleCells = [tableView visibleCells];
for (UITableViewCell *cell in visibleCells) {
[cell setAccessoryType:UITableViewCellAccessoryNone];
}
// Now do whatever else you want in response to a row being selected.
}
You should set the accessorytype in tableView:willDisplayCell:forRowAtIndexPath: instead of cellForRowAtIndexPath so that it is updated whenever it is displayed (and not just when created).
There is a tableview method called clearsselectiononviewwillappear that you might have accidentally overwritten. The default behavior should be YES. Check out Apple's doc
on UITab
i am using custom UitableViewcell (MainTablecell)to display the records. i am also providing edit and delete functionality.so that i want to shrink my custom table cell, can any one suggest me how to do this.my custom cell looking like bellow
cell.shouldIndentWhileEditing = YES;
and
-(BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
i tried with above poece of code but
Both are not working for me,How can i shrink all lables in my cell could you please help for me
When your tableView goes into edit mode, resize the labels.
shouldIndentWhileEditing: only makes the left side of the cell indent and does nothing for the content. You will need to manually resize the labels.
Depending on the design and code of that custom cell, you can call the label and perform setFrame: when in editing mode, just detect that mode and reload your tableView.
When setting [self.tableView setEditing:TRUE]; on a tableView the native table delete editing icons appear to the left. But when using a plain styled table these round icons pushes my row background (and content) to the right.
How can I prevent the editing style from changing my cell position, and instead put the icon on top off the cell?
The way it is now it looks like a bug.
Another question on this. Is there some way to define indexPath.row == 0 to not have an delete icon on setEditing:TRUE?
Set cell's shouldIndentWhileEditing property to NO.
Implement delegate's tableView:editingStyleForRowAtIndexPath: method and return appropriate value from it, e.g.:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0)
return UITableViewCellEditingStyleNone;
return UITableViewCellEditingStyleDelete;
}
Ok, found why #1 was not working. I hade set my row background as a view on cell.contentView, in stead of putting it on cell.backgroundView. This way the built in functionality could not separate background from content.
The shouldIndentWhileEditingRowAtIndexPath function will only prevent background from indenting, and not content, as there has to be room for the editing icon.