I'm trying to implement a UIRefreshControl
onto my UITableView
without having to have a TableViewController and setting the 'Refresh' to Enabled.
So far I've globally declared the following in my ViewController.h file:
@property (strong, nonatomic) UIRefreshControl *refreshView;
-(void)refreshTableView;
And have added the following code to my viewDidLoad
in the ViewController.m file:
self.refreshView = [[UIRefreshControl alloc] init];
self.refreshView.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull To Refresh"];
[self.refreshView addTarget:self action:@selector(refreshMyTableView) forControlEvents:UIControlEventValueChanged];
[self.tableView addSubview:self.refreshView];
Finally, I have this method to go with it, in my ViewController.m file:
-(void)refreshTableView {
[self.tableView reloadData];
[self.refreshView endRefreshing];
}
What am I doing wrong? Any light on this matter will be greatly appreciated! :)
What are you trying to do using this code ?
self.refreshView = self.refreshView;
Change that and try with:
[yourTableView addSubview:self.refreshView];