是否可以在节标题下添加刷新控件

时间:2017-12-29 05:44:27

标签: ios swift tableview

我有一个带有节头的表格视图。我想在节标题下面添加刷新控件,而不是在tableview的顶部。这可能吗?

2 个答案:

答案 0 :(得分:1)

否。这是不可能的。尝试在节标题中添加活动指示符。 如果您希望仅当用户在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
}

答案 1 :(得分:0)

不可能,因为节头是tableView的一部分。

您可以将视图添加为节标题的一部分,但位于UITableView的顶部。