开发者

Find object by tag

开发者 https://www.devze.com 2023-01-27 04:54 出处:网络
I have UITableView with UITextFields inside cells. Every UITextField has his own tag. How to access UITe开发者_如何学编程xtField by tag? I was trying to google that answer, but looks like first 5 page

I have UITableView with UITextFields inside cells. Every UITextField has his own tag. How to access UITe开发者_如何学编程xtField by tag? I was trying to google that answer, but looks like first 5 pages shows how to check tag of sender.


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

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


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]; }


Solved:

Create pointers in @interface, and do:

self.carBody = cellTextField;
0

精彩评论

暂无评论...
验证码 换一张
取 消