简体   繁体   中英

UITableView Last cell

我怎么知道何时显示UITableView的最后一个单元格,何时数据来自数据库并且我不知道确切的单元格数量。

If you know your number of cells in the table and you wish to just know when the last row will appear, you could implement:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

and compare the row with your table rowcount. This method it being triggered just before a row to be shown.

-(NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section 

此函数从ur表视图返回单元格的no

The proper way to handle a table view is to define a number of sections and a number of rows in each section for your table view in the table view controller. If you don't know the length of the table, you're already in trouble.

A common way to handle this is to load your data from the database into an array and then use the length of the array as the table length. Once you have that, the UITableViewController class should have some sort of method for getting the index path of the last cell. Once you have that you call '[indexPath row]' and you're golden. Read up on UITableViews it's a complex subject if you go into depth.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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