我正在用Objective C构建一个iPhone应用程序。在我的应用程序中,我正在绘制图像上的描边,并且想要实现撤消和重做功能。我为此已使用NSUndoManager
。有了这个功能,我可以在一个层次上撤销我的绘图,但是我的要求是在最低可能级别(或至少最低10级)撤消绘图。我已经将setLevelsOfUndo
设置为10,但它不起作用。NSUndoManager没有为UnDo /重做图形的iPhone应用程序保留重做/撤消堆栈
我用下面的代码:
- (void)UnDoImage1:(UIImage*)image
{
if (capturedImage.image != image)
{
[self.managedObjectContext.undoManager undo];
[[self.managedObjectContext.undoManager prepareWithInvocationTarget:self] UnDoImage1:capturedImage.image];
[capturedImage release];
capturedImage.image = [image retain];
}
}
请让我知道我在哪里不正确。我已经为此长期使用了Google,但没有找到功能失败的确切原因。