如何为多个UIView添加撤消管理器 [英] how to add undo manager for multiple UIView
问题描述
我需要一些有关如何使用UndoManager执行撤消操作的想法.
I need some idea to how perform undo opertaion with UndoManager.
在我的应用程序中,用户可以在屏幕上添加尽可能多的礼物(UIView).他可以重新安排&调整该屏幕上所有已添加礼物的大小.
In my app user can add as many gifts (UIView) on a screen. He can rearrange & resize all added gifts on that screen.
用于添加,重新排列&调整礼物大小后,我做了一个UIView&在该课程中,我已经为触摸委托实现了相同操作的代码.
For adding, rearranging & resizing gifts, I have made a subclass of UIView & in that class I have implemented code for the same operations on touch delegates.
现在我的问题是,如果用户重新布置了多个礼物,还调整了其中一些的尺寸,我该如何实施unanamanger将所有礼物恢复到原来的位置.
Now my question is that if user has rearranged multiple gifts & also resize some of them, how I can implement a undomanager to restore all the gifts in original position.
任何想法或建议现在都很好.
Any idea or suggestion would be great at this time.
推荐答案
如果您要撤消位置更改,请调整大小&旋转 UIViews
,您需要握住框架,并在手势开始时对其进行变换.这样,在执行撤消操作时,您可以还原为初始值.
If you want to undo the change of position, size & rotation of UIViews
, you need to hold the frame, transform of it when the gesture started. So that when perform undo, you can revert to the initial values.
您可以参考以下 answer
这篇关于如何为多个UIView添加撤消管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!