ACEDrawingView icon indicating copy to clipboard operation
ACEDrawingView copied to clipboard

Save the drawing and open it again

Open thomasSailing opened this issue 11 years ago • 5 comments

many thanks for this great sample project. I want to ask if you can give me a tip. I want to save the drawn lines, shapes, etc.. I do not mean save as png or pdf. Rather, I want to save the contents of the "self.pathArray" and load this data later in the "drawingView". Later the drawing is to be further processed. If there still remain the UnDo steps, it would be perfect.

I try and try ... but do not get ahead. it would be great if you could help me. sincerely thomas.

thomasSailing avatar Mar 27 '14 12:03 thomasSailing

We would need to have all the drawing tools adhere to the NSCoding protocol. UIBezierPath already supports it, but we also need to (de)code the colors, line size, etc.

If someone feels like sending a pull-request, that would be useful.

vtourraine avatar Jun 18 '15 10:06 vtourraine

Just adding how I did this, incase some one is in need.

  1. Make the following code public in ACEDrawingView.h
@property (nonatomic, strong) NSMutableArray *pathArray;
@property (nonatomic, strong) NSMutableArray *bufferArray;

- (void)updateCacheImage:(BOOL)redraw;
  1. Save pathArray and bufferArray from the previous instance of ACEDrawingView.
  2. When a new ACEDrawingView (let it be 'drawView') is created provide it with the values from previously saved pathArray and bufferArray.
  3. Over ride layoutSubviews() in parent view and call the method drawView.updateCacheImage(True)

Note: drawView.updateCacheImage(True) will work only when its called before the view is displayed. I found that calling this method after view is loaded, some how makes the drawings hidden and appears when we draw over it again.

Disclaimer: Not tested properly. Will add the issues after I finish testing.

vipinjohney avatar Aug 02 '16 13:08 vipinjohney

Hi,vipinjohney I also want to save the drawing and open it again.do you finish testing ? thanks.

wangsuikang avatar Oct 08 '16 08:10 wangsuikang

Hi vipinjohney

I need to update previous draw lines with selected pattern image.could you help me in this issue. I did what you said above redrawing is working perfectly but those line were not update.

SidduIOS avatar Jan 19 '17 06:01 SidduIOS

Above solutions by me had many issues. One of them was, each time I redraw the saved lines and draw a new line the previous set of lines changed their location. Tried to fix that but dropped it due to lack of time .

vipinjohney avatar Feb 23 '17 12:02 vipinjohney