Obj-C,应用程序在 UIImageView 周围移动但需要返回视图并重置位置?
我可能错误地设置了 UIImageViews。我将它们添加到界面生成器中。然后,我允许它们通过 touchbegan 等在视图中移动。
我正在使用导航控制器,我需要将 UIImageViews 的位置重置为加载视图时它们的位置。
我以为我可以在 viewWillAppear 中重新初始化它们,但我似乎无法做到这一点。
有人可以建议我应该做什么才能使此功能发挥作用吗?
I've probably setup the UIImageViews incorrectly. I added them in interface builder. I then allow them to be moved around the view with touchbegan etc.
I'm using a navigation controller and I need to have the positions of the UIImageViews reset to how they were positioned when the view was loaded.
I thought I could re-initialize them in viewWillAppear, but I don't seem to be able to do this.
Can someone advise me what I should do to make this functionality work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须将位置存储在某个地方。您甚至可以子类化 UIImageViews 并放入自定义属性,例如 CGPointinitialPosition。
您也可以再次加载 nib 文件,并尝试将其中找到的 UIImageView 映射到当前显示的 UIImageView,但就我个人而言,我会坚持使用某些本地存储。
You'll have to store the positions somewhere. You could even subclass the UIImageViews and put in a custom property like
CGPoint initialPosition
.You could as well load the nib file again and try to map the UIImageViews you find in it to the ones you are currently showing, but personally I'd stick to some local storage.