gpt4 book ai didi

ios - 如何向 uiTableView Controller 添加滑动和标题 View 。?

转载 作者:行者123 更新时间:2023-11-29 00:29:17 26 4
gpt4 key购买 nike

this the first screenshort

enter image description here

我添加了一个标题 View 并向左滑动到 TableView Controller 。

正如您在屏幕截图中看到的那样,当我滑动行时标题 View 也会移动,请帮助我。

我添加标题的代码是

     func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {

let header = tableView.dequeueReusableCell(withIdentifier: "HeaderCell") as! CustomHeaderTableViewCell

header.SortButton?.backgroundColor = UIColor(netHex:0xEEEEEE)
header.FilterButton?.backgroundColor = UIColor(netHex:0xEEEEEE)

header.SortButton?.font = UIFont.fontAwesome(ofSize: 18)
header.SortButton?.text = String.fontAwesomeIcon(name: .sort) + " Sort"

header.FilterButton?.font = UIFont.fontAwesome(ofSize: 18)
header.FilterButton?.text = String.fontAwesomeIcon(name: .filter) + " Filter"

return header

}



func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? {
let more = UITableViewRowAction(style: .normal, title: "More") { action, index in
print("more button tapped")
}
more.backgroundColor = .lightGray

let favorite = UITableViewRowAction(style: .normal, title: "Favorite") { action, index in
print("favorite button tapped")
}
favorite.backgroundColor = .orange

let share = UITableViewRowAction(style: .normal, title: "Share") { action, index in
print("share button tapped")
}
share.backgroundColor = .blue

return [share, favorite, more]
}

func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}

func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
searchBar.endEditing(true)

let translation = scrollView.panGestureRecognizer.translation(in: scrollView.superview)

if(translation.y > 0)
{
// react to dragging down
} else
{
// react to dragging up
}
}

请帮我解决滑动问题。

还有一件事我可以隐藏滚动上的标题 View 。

最佳答案

您的问题有 2 种可能的解决方案:

  1. 只需在 viewForHeaderInSection 函数中返回 cell.contentView 而不是 cell,您的问题就会得到解决。
  2. 子类 UITableViewHeaderFooterView 而不是 UITableViewCell 用于您的页眉 View 。

关于ios - 如何向 uiTableView Controller 添加滑动和标题 View 。?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42292128/

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