textFieldDidEndEditing触发“时间太晚"; [英] textFieldDidEndEditing firing "too late"
问题描述
我有一个多视图过程,用户正在输入数据,并且在此过程的每一步都将其保存到模型类属性中.
I have a multiview process the user is entering in data and I'm saving it to the model class properties each step along the way.
我使用textFieldDidEndEditing
检查输入是否有效,如果有效,则保存输入的数据.
I use textFieldDidEndEditing
to check if the input is valid, and if so, saves the entered data.
在该视图上,我有一个continueButtonClicked事件,该事件检查所有验证是否通过,如果通过,则加载下一个视图.我不在这里设置模型的属性,因为我认为不必这样做,因为每个字段一次都保存到模型1字段中.但是,我注意到了一些问题.
On the view I have a continueButtonClicked event that checks to see if all the validations pass and if so loads the next view. I do NOT set the properties of the model here, because I think I shouldn't have to since each field is saved to the model 1 field at a time. However, I noticed some issues.
如果用户在文本框内并单击继续"按钮,则在textFieldDidEndEditing
之前将触发continueButtonClicked事件.最终发生的事情是,在textFieldDidEndEditing
中进行保存之前,下一个视图已使用旧"模型填充.
If the user is inside of a textbox and clicks the "Continue" button, the continueButtonClicked event fires BEFORE the textFieldDidEndEditing
. What ends up happening is that the next view is populated with the "old" model prior to the save happening in textFieldDidEndEditing
.
我想念什么?在继续"上设置所有属性是否合适?如果我正在为网络编程,那将是这样做的方式,但对于本机应用程序似乎并不正确.
What am I missing? Is it proper to set all the properties on the Continue? That's how I would do it if I were programming for the web, but it doesn't seem right for a native app.
推荐答案
可以代替尝试一下,看看是否能解决您的问题?
Can you try this instead and see if that solves your problem?
textFieldShouldEndEditing:
这篇关于textFieldDidEndEditing触发“时间太晚";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!