gpt4 book ai didi

ios - 隐藏 UITableViewCell 中的行

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

如何配置下面的表格 View 以仅反射(reflect)具有未隐藏单元格的行?这是带有相关 TableView 的 View Controller 的代码:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

let post = posts[indexPath.row]
if let cell = tableView.dequeueReusableCellWithIdentifier("favorCell") as? FavorCell {
cell.configureCell(post)
cell.hidePost(post)
return cell
} else {
return FavorCell()
}
}

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return posts.count
}

这是我的 TableViewCell 中用于隐藏单元格的函数:

func hidePost(post: Post){  
self.post = post
if post.username != uid {
self.hidden = true
}
}

最佳答案

制作两个数组并根据您的情况使用,并在任何更新后重新加载您的表。

例如:

if(is_searching == true) {
cell.textLabel?.text = Array1[indexPath.row]["xyz"] as! NSString as String
cell.accessoryView?.hidden = true

}
else {
cell.textLabel?.text = Array2[indexPath.row]["xyz"] as! NSString as String
}

不要忘记重新加载表格。

关于ios - 隐藏 UITableViewCell 中的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36009626/

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