Selected Row Checkmark color changing - ios

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.

Related

Remove the UItableview cell segue button?

I was just wondering if it was possible to remove the button that is automatically added to the UItableview cell when creating a segue in storyboard between the cell background and the destination view. For my app, it takes up to much space. I'd rather the user just tap any where on the cell to activate the segue.
Does anyone know how to do this? When I select the button in the cell and hit delete, the whole cell deletes.
Try adding the following code to your cellForRowAtIndexPath method:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
cell.accessoryType = UITableViewCellAccessoryNone;
}
eddwinpaz answer is what worked for me (as I was using storyboard and not doing it with code)
"Select on storyboard Atributes inspector and select the tablecell you don't want it to appear the Accesory and then select Accessory: none"

How to change cell content on highlight

In my TableView i load cells based on a xib file. The cell has a imageView in the background. How to change the image when user holds finger on a row? I dont meen didSelectRowAtIndexPath, cause it means the user tapped the row.
Implement the - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated method on your cell subclass and change the image there based on the value of the highlighted parameter.
Hope this help
- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath{
// update your image here
return YES;
}

TableView Color resets after scroll

The table view I have changes Cell background colors quite often. The colors set in -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath are fine but some colors are set after the table view loads like:
- (void) ChangeCellColorAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:currentCell inSection:0]];
cell.backgroundView.backgroundColor = [UIColor orangeColor];
}
If a cell is changed with that method it will revert back to what it was originally set to when it scrolls out of view. How can I insure it will stay the same color when I scroll out of view.
You should take into account how the cell loading process works: when you set the color of a visible cell and the user scrolls to a point where that cell is not visible, and then scrolls back to the original point the table view will call again tableView:cellForRowAtIndexPath:, a new cell will be created(better said an already created cell will be reused if you are doing things correctly as I assume) and the background color you previously set will be ignored.
The solution is to know which color each cell should have in tableView:cellForRowAtIndexPath: and set the color there.

dim everything but selected row ios

How could I easily dim the complementary set of rows, when one gets selected.
Right now I have the code to select a cell so I can call a method on it, but I would like to set opacity of all the other rows.
-(void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
SummaryCell * selectedCell = [tableView cellForRowAtIndexPath:indexPath];
[selectedCell manageContent];
}
Edit: I dont want to iterate through all the other cells (because there will be a lot of them) - wouldn't it be easier to add an UIView above all other cell (this would also prevent user interaction) and place the selected cell above that view (something like increasing z-index in HTML).
It depends what you mean by "dim" the other rows. The process to iterate over all visible rows and to set a property on all the rows other than the one selected is as follows:-
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
for (UITableViewCell *otherCell in self.tableView.visibleCells) {
NSIndexPath *otherIndexPath = [self.tableView indexPathForCell:otherCell];
if (![indexPath isEqual:otherIndexPath]) { // exclude the selected cell
// Do whatever you want with otherCell here
}
}
}
Where my comment is, you can set whatever properties you like on otherCell. For example, otherCell.alpha which is the alpha (transparency) of that cell.
You can iterate all the visible cells, configure them to be dimmed, then on the datasource cellForIndex method check if there's a selected cell, if there is, check if it is at the asked index, if so configure the cell as selected, if not as dimmed.

how to uncheck all cells on tableview in ios

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

Resources