I have an UIView BoardView in which I draw lines. When I push a cell in a table view, I draw a line in BoardView.
When I push the first cell everything is ok, the lines is drawn. Now, if I push a second cell, I would like erase the first line and draw the second line.
I have a boolean to know if I have to draw lines or not.
In a viewController :
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(self.boardView.drawLine) {
self.boardView.drawLine = NO;
[self.boardView setNeedsDisplay]; //redisplay the context without lines
}
Path * path = [self.grid.sommesPathArray objectAtIndex:indexPath.row];
[self.boardView drawPath:path];
self.boardView.drawLine = YES;
[self.boardView setNeedsDisplay]; // display the context with a line
}
In BoardView.m :
- (void)drawRect:(CGRect)rect {
if (self.drawLine) {
for(Line * line in lines)
[self drawLineWithContext: UIGraphicsGetCurrentContext() andLine:line]; //draw lines
}
}
My problem is that the lines aren't deleted.