gpt4 book ai didi

ios - 如何在 tableview 中重用动态原型(prototype)单元格

转载 作者:行者123 更新时间:2023-11-29 11:35:05 24 4
gpt4 key购买 nike

我在 tableview 中创建了一个原型(prototype)单元格,我想重新使用它来节省内存。

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
mytesttableviewcell *cell=[self.tbl dequeueReusableCellWithIdentifier:@"Test"];
cell.txt1.text=@"1234567890";
cell.txt2.text=@"1234567890";
return cell;
}

我找不到办法做到这一点。关于如何完成的任何想法

最佳答案

根据 Docs dequeueReusableCellWithIdentifier UITableView 的实例方法

A table view maintains a queue or list of UITableViewCell objects that the data source has marked for reuse. Call this method from your data source object when asked to provide a new cell for the table view. This method dequeues an existing cell if one is available or creates a new one using the class or nib file you previously registered. If no cell is available for reuse and you did not register a class or nib file, this method returns nil.

关于ios - 如何在 tableview 中重用动态原型(prototype)单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50089560/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com