TableViewにTextFieldをセットしあり、それを全て取得したい状況ができた。
その時に全てのセルの1個1個を取得するにはどうすればいいだろうと調べた時のメモ。
以下のようにcellをループで回せる
NSMutableArray *cells = [[NSMutableArray alloc] init]; for (NSInteger j = 0; j < [tableView numberOfSections]; ++j) { for (NSInteger i = 0; i < [tableView numberOfRowsInSection:j]; ++i) { [cells addObject:[tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:j]]]; } }
上記ではcellsという変数に一度入れなおしてるが、別にfor文でそのまま回して処理しても構わない。
自分の作ったcellForRowAtIndexPathとかがもう1回呼ばれるのではとか思ったりしたけど、
そういうわけではなく、現在のcellを取得できる。
ちなみに今画面を表示しているセルを取得するには以下を用いる。
NSArray *cells = [tableView visibleCells];
これで表示しているセルだけを更新とかできるのでreloadDataよりもコスト少なめに画面更新ができる。
こんにちは。virapture…
View Comments
I may need your help. I've been doing research on gate io recently, and I've tried a lot of different things. Later, I read your article, and I think your way of writing has given me some innovative ideas, thank you very much.
I have read your article carefully and I agree with you very much. This has provided a great help for my thesis writing, and I will seriously improve it. However, I don't know much about a certain place. Can you help me? https://www.gate.io/es/signup/XwNAU
Your article gave me a lot of inspiration, I hope you can explain your point of view in more detail, because I have some doubts, thank you.
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me? https://accounts.binance.com/ph/register?ref=V2H9AFPY
Thanks for sharing. I read many of your blog posts, cool, your blog is very good.
Thanks for sharing. I read many of your blog posts, cool, your blog is very good.