简体   繁体   English

如何以编程方式获取在其中创建新UITableViewCell的行?

[英]How can I programmatically get the row at which a new UITableViewCell is created?

Because my UITableView gets sorted by a date (not the current date), most of the time, when I tap a UIButton called: Add a new entry to a NSMutableArray gets added [cellList addObject:managedObject] which is the UITableView 's datasource, then the UITableView gets reloaded so that the new UITableViewCell is displayed. 因为我的UITableView是按日期(不是当前日期)排序的,所以在大多数情况下,当我点击一个UIButtonAdd一个新条目到NSMutableArray会添加[cellList addObject:managedObject] ,这是UITableView的数据源,然后重新加载UITableView ,以便显示新的UITableViewCell I want to get the indexPath of that new cell. 我想获取该新单元格的indexPath But Like I said, since my UITableView gets sorted by a date, the cellList 's indexes doesn't always correspond to the UITableView 's. 但是就像我说的那样,由于UITableView按日期排序,因此cellList的索引并不总是对应于UITableView的索引。

So how can I get the indexPath of the cell that was just created by reloading the table's data? 那么,如何通过重新加载表数据来获取刚刚创建的单元格的indexPath?

Any idees would be much appreciated! 任何想法将不胜感激!

Look for documentation of NSIndexPath. 查找NSIndexPath的文档。 It has properties like row & sections. 它具有行和节之类的属性。 I hope it should solve your needs. 希望它能解决您的需求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM