I know how to add pull-to-refresh into a view controller. But right now the situations is: I have a UIView
& that contains a UITableView
and I want to pull the table view up at the very bottom of tableview to reload it's data.
How to add pull-to-refresh inside this UITableView
, not it's parent view's controller.
You can add a refresh control to a table or collection view by assigning an instance of the UIRefreshControl class to this property. If your application targets versions prior to iOS 10, you simply add the refresh control as a subview to the table view.
In your ViewDidLoad add this:
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
[self.myTableView addSubview:refreshControl];
And refresh
- (void)refresh:(id)sender
{
// do your refresh here and reload the tablview
}
it's simple: Take one UIScrollView
and inside it take UITableview
and put in bottom of UITableView
and just write Scrollview delegate method
#pragma mark -
#pragma mark - Scroll View Delegate Method
- (void) scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView == scrollObj) {
CGFloat scrollPosition = scrollObj.contentSize.height - scrollObj.frame.size.height - scrollObj.contentOffset.y;
if (scrollPosition < 30)// you can set your value
{
if (!spinnerBottom.isAnimating) {
[spinnerBottom startAnimating];
[self YourPUllToRefreshMethod];
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With