Find object by tag

橙三吉。 提交于 2019-12-24 09:48:44

问题


I have UITableView with UITextFields inside cells. Every UITextField has his own tag. How to access UITextField by tag? I was trying to google that answer, but looks like first 5 pages shows how to check tag of sender.


回答1:


You can get the reference using viewWithTag and send message to the reference as you do normally.

UITextField *tfObj=(UITextField*)[tblVuObj viewWithTag:1];



回答2:


A UITableView only holds visible cells. Therefor, you cannot access cells that are not visible. To iterate through visible cells:

for ( UITableViewCell *aCell in [theTable visibleCells] ) {   UITextField *aField = (UITextField *)[aCell viewWithTag:kYourTextFieldTag]; }




回答3:


Solved:

Create pointers in @interface, and do:

self.carBody = cellTextField;


来源:https://stackoverflow.com/questions/4281788/find-object-by-tag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!