iPad 清除所有字段返回开始
我正在创建一个内部 iPad 应用程序,我们的员工可以在其中填写他们刚刚进行的现场访问的详细信息。
应用程序中的一个页面是一个巨大的表单,用户可以在其中输入所有信息。我在这个表格上有一个重置按钮。此按钮将仅清除所有文本字段、文本视图、取消选中复选框等。
是否有一种干净的方法将视图重置为状态,就好像它是全新的(不脏)一样。我真的不想检查视图上的每个控件并将其设置回空。
有没有办法擦除整个视图并重新启动?
提前致谢
Im creating an internal ipad app for which will allow our employees to fill in details on a site visit they have just performed.
One of the pages in the app is a massive form where the user enters all the information. I have a reset button on this form. This button will just clear all textfields, textviews, uncheck checkboxes etc etc.
Is there a clean way to reset a view to the state as if it is brand new (not-dirty). I dont really want to go through every control on the view and set it back to nothing.
Is there a way to wipe the entire view and restart again?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为做到这一点的简单方法是,
I think the easy-way to do this is by,
我认为最简单的方法是放弃您的视图(或您想要重置的部分)并重新创建它们。这可能很简单:
更复杂但可能值得的可能是让您的视图对象使用 KVO 来监视通过委托或超级视图作为属性公开的某些模型对象的更改。如果您希望视图能够自动更新自身以响应来自视图其他部分或某些外部源(例如网络更新)的模型更改,这会很方便。然后,“重置”就像用模型的新实例替换视图正在观察的属性值一样简单。
I think the easiest way to do this is to discard your view (or the sections of it you want to reset) and recreate them. That might be as simple as:
More complex but possibly worthwhile could be to have your view objects use KVO to watch for changes to some model object exposed as a property through a delegate or on a superview. That's handy if you want the view to be able to automatically update itself in response to changes to the model coming from other parts of the view or some external source like network updates. A "reset" could then be as simple as replacing that value of the property the views are observing with a new instance of your model.