我有一个带有节头的表视图。我想在节标题下面添加刷新控件而不是在tableview的顶部。这可能吗?
不可以。这是不可能的。尝试在节标题中添加活动指示器。如果您希望仅在用户下拉而tableview内容偏移为0时显示活动指示符,则尝试添加平移手势并仅针对此特定条件实施
var panGesture = UIPanGestureRecognizer(target: self, action: #selector(swipedDown))
self.HometableView.addGestureRecognizer(panGesture)
panGesture.delegate = self as! UIGestureRecognizerDelegate
//处理平移手势的代码
func swipedDown(panGesture: UIPanGestureRecognizer)
{
let velocity: CGPoint = panGesture.velocity(in: HometableView)
if velocity.y > 0 {
print("gesture moving Up")
if(HometableView.contentOffset == CGPoint.zero)
{
print("************SWIPED DOWN")
//Do the logic to increase section header height and show the activity indicator
}
}
else {
print("gesture moving Bottom")
}
}
func gestureRecognizerShouldBegin(_ panGestureRecognizer: UIPanGestureRecognizer) -> Bool {
let velocity: CGPoint = panGestureRecognizer.velocity(in: HometableView)
if velocity.y > 0 {
if(HometableView.contentOffset == CGPoint.zero)
{
return true
}
}
return false
}
不可以,因为节头是tableView的一部分。
您可以将视图添加为节标题的一部分,但位于UITableView的顶部。