How to undo and undo a smooth line in iPhone?

I am working on an application and I need to draw a smooth line, so I followed this link to smooth the ruler of the smooth iPhone sketching algorithm , and I followed the answer kyoji. But now I do not know how to implement the functionality of Undo Redo.

Please, help

+5
source share
1 answer

Use NSUndoManager. However, if you draw lines on the canvas, you will also need to keep their view around (so that you can turn them off).

So, whether you collect them as UIBezierPath or use form layers or your own "array of points", you cancel in the same way.

, , , . (, touchEnded), "" , . , - -...

- (void)pushDrawing:(Drawing*)drawing
{
    [self.stack push:drawing];
    [self.undoManager registerUndoWithTarget: self
                                    selector: @selector(popDrawing)
                                      object: nil];
}

- (void)popDrawing:(Drawing*)drawing
{
    Drawing *drawing = [self.stack pop];
    [self.undoManager registerUndoWithTarget: self
                                    selector: @selector(pushDrawing:)
                                      object: drawing];
}

, , . , ...

NSUndoManager... iOS . "", , , ( , ).

0

All Articles