IOS How to implement UITableView low-level update control

I just want to know if there is a way to implement the bottom update control using UIRefreshControl without any third-party libraries.

Thanks in advance.

+4
source share
3 answers

You can add a footer to the table view section, set the Refresh view func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView?if the footer loads, and then call up the next set. Refresh animation.

May solve your problem this way.

Hth, enjoy coding!

+3
source

, -.

scrollViewDidScroll

UIScrollView Bottom, UIView, UITableView.

scrollViewDidScroll

 func scrollViewDidScroll(scrollView: UIScrollView) {
    let scrollOffset : CGFloat = scrollView.contentOffset.y
    let scrollHeight : CGFloat = scrollView.frame.size.height

    let scrollContentSizeHeight : CGFloat = scrollView.contentSize.height + scrollView.contentInset.bottom

    let tableFrame : CGRect = self.tableView.frame

    if (scrollOffset + scrollHeight) >= scrollContentSizeHeight {
        self.bottomRefreshAnimation()
    } else {
        if self.tableView.frame.origin.y < 0 {
            UIView.animateWithDuration(0.2, delay: 0.0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
                self.tableView.frame.origin.y = self.tableView.frame.origin.y + 40
                }, completion: nil)
        }
    }
}

self.bottomRefreshAnimation() UIView

 func bottomRefreshAnimation(){
    if self.tableView.frame.origin.y > 0 {

        UIView.animateWithDuration(0.4, delay: 0.0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
            self.tableView.frame.origin.y = self.tableView.frame.origin.y - 40
            }, completion: nil)

        populateData({ (finished) -> () in
            UIView.animateWithDuration(0.2, delay: 0.0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
                    if self.tableView.frame.origin.y < 0 {
                        self.tableView.frame.origin.y = self.tableView.frame.origin.y + 40
                    }
                }, completion: nil)
        })
    }
}

, , UITableView Origin.y 40, UIView .

, , ,

.

+3

, : UIRefreshControl UITableView iOS6?

View, :

[self.tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationFade];
+1
source

Source: https://habr.com/ru/post/1584402/


All Articles