I just want to know if there's a way to implement the bottom refresh control with the use of UIRefreshControl without any third party libraries.
Thanks in advance.
I just want to know if there's a way to implement the bottom refresh control with the use of UIRefreshControl without any third party libraries.
Thanks in advance.
You can add footer to the tableview section, set Refresh view, with func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView?
, if the footer get load then call the next set Refresh animation kind of things.
May solve your problem with such way.
HTH, Enjoy Coding !!
Alright so after some time and with all the comments and answers above i came up with something.
with the use of scrollViewDidScroll i have implemented bottom refresh
if the UIScrollView have reached Bottom it slides up a UIView and after the execution it auto slides back down and reloads the UITableView.
The scrollViewDidScroll function
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)
}
}
}
and the self.bottomRefreshAnimation() contains the code to animate the UIView from the bottom
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)
})
}
}
Most importantly what it does is it checks for the UITableView Origin.y and reduces the size by 40 while the UIView is sliding up.
Hopefully this will help you guys and if there are better ways to achieve this please let me know
Thanks for all the reply's.
This should be what you are looking for: UIRefreshControl at the bottom of the UITableView iOS6?
You can also refresh any row of a tableView using:
[self.tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationFade];