I have an application that allows the user to move UIViews up and down giving the appearance one view can be on top of another. Changing the "level" (index in the parent's subviews) of the UIView is pretty simple by changing the index of the UIView in the superview using the exchangeSubviewAtIndex method.

         /---------/
IDX 1   /    A    /
       /---------/
         /---------/
IDX 0   /    B    /
       /---------/


Move 'A' Down


         /---------/
IDX 1   /    B    /
       /---------/
         /---------/
IDX 0   /    A    /
       /---------/

Now, I'm using the NSUndoManager to record the change so the user can undo the move down action. This is working fine. The issue comes in when trying to do the redo message on the NSUndoManager. Since there is no state for "ZIndex" (because it's a position in it's parent's view) on the UIView that was being moved, the redo doesn't do anything....

Is there a way to explicitly pass in a redo invocation for redo?

有帮助吗?

解决方案

Ok, my issue was a misunderstanding of the redo part of the undo manager. Turns out the undo manager's redo is another undo, it just knows it's in the undo process and adds the invocation to the redo stack.

This post was my key: NSUndoManager: redo not working

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top