这可能是一个简单的问题.重置UITableViewCells的帮助 [英] This might be a simple question. HELP with Resetting UITableViewCells
问题描述
我有一个严重的疑问.这可能很简单,但是我需要一些帮助.
I have a serious doubt. It may be simple, but I need some help with this.
我有一个视图(view1),然后导航到(view2).在View 2中有一个tableView带有一些textFields(作为SubView添加),我在UITableViewCells中的textFields中添加了一些数据.
I have a view (view1) and I navigate to (view2). There is a tableView in View 2 with some textFields (added as a SubView) , and I add some data to the textFields in the UITableViewCells.
我按下后退"按钮,然后返回查看1..
I press the back button, and I go back to view 1.
如果我再次导航到视图2,则textFields的状态与我之前离开的状态完全相同.我希望它为零,并在其中显示占位符.如何在不中断所有其他数据的情况下再次使textFields为零?
If I navigate again to view 2, the textFields are in the exact same state as I had left it before. I want it to be nil, and show the placeholders in them. How do I make the textFields nil again without disrupting all the other data ?
我在视图1中使用了NSUserDefaults来让视图2知道我正在导航.但是...方法-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
和 viewDidLoad
似乎没有再次被调用.只有再次调用它,我才能使uitableViewCells内部的textField为 nil
.
I used NSUserDefaults in view 1 to let view 2 know that I am navigating. But ... the method
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
and viewDidLoad
does not seem to be called again. Only if it is called again, I can make the textFields inside the uitableViewCells nil
.
有人可以告诉我每次导航到view2时如何调用tableViewCells吗?
Could someone tell me how I can call the tableViewCells everytime a navigate to view2 ?
推荐答案
我简直不敢错过.我不知道是否应该删除此问题...
I cannot believe I missed this. I do not know if I should delete this question...
- 我使用了一个简单的
[tableView reloadData]
; - 在
viewDidAppear
; 中使用了它
- I used a simple
[tableView reloadData]
; - Used it in
viewDidAppear
;
这两个简单的事情就成功了!
These two simple things did the trick !
这篇关于这可能是一个简单的问题.重置UITableViewCells的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!