-3

when i refresh the table then its is no refresh and not show the circle on the screen . This is my code:-

refreshControl = [[UIRefreshControl alloc]init];

[self.tableHolidays addSubview:refreshControl];

[refreshControl addTarget:self action:@selector(refreshTable) forControlEvents:UIControlEventValueChanged];

- (void)refreshTable {
    [refreshControl endRefreshing];
    [self.tableHolidays reloadData];
} 
Desdenova
  • 5,326
  • 8
  • 37
  • 45
Pooja Puri
  • 77
  • 5
  • [UIRefreshControl](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIRefreshControl_class/) – Desdenova Dec 22 '15 at 10:07
  • try endRefreshing after reloadData. [self.tableView reloadData]; [self.refreshControl endRefreshing]; – Suhail kalathil Dec 22 '15 at 10:08
  • @Suhailkalathil it doesnt matter, the matter is the code in the `refreshTable` func, that code he provide doesnt do anything at all, no circle can be magically appear when call that 2 lines, atleast have to give that drawing or something code – Tj3n Dec 22 '15 at 10:10
  • is your tableview is samller than it's frame ... ?(i mean number of rows) – Mihir Mehta Dec 22 '15 at 10:13
  • @Tj3n.. what about this .. self.refreshControl = [[UIRefreshControl alloc] init]; [self.refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged]; [self.tableView addSubview:self.refreshControl]; } - (void)refresh:(UIRefreshControl *)refreshControl { [self downloadFeed]; } -(void)downloadFeed{ [self.tableView reloadData];[self.refreshControl endRefreshing];} – Suhail kalathil Dec 22 '15 at 10:13
  • check this link http://stackoverflow.com/a/22060573/5362916 – Uma Madhavi Dec 22 '15 at 10:18

3 Answers3

1

Try interchanging the sequence

- (void)refreshTable {

    [self.tableHolidays reloadData];
    [refreshControl endRefreshing];
} 
Mihir Mehta
  • 13,743
  • 3
  • 64
  • 88
0
- (void)viewDidLoad 
{
    [super viewDidLoad];
    UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
    [refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
    [self.tableView addSubview:refreshControl];
}

- (void)refresh:(UIRefreshControl *)refreshControl
{
    // Do your stuff here, when done:
    [refreshControl endRefreshing];
}
user3182143
  • 9,459
  • 3
  • 32
  • 39
0

First complete all operations on Table while refreshing & then end refreshing.

- (void)refreshTable { [self.tableHolidays reloadData]; [refreshControl endRefreshing]; }

Hemali Luhar
  • 349
  • 1
  • 11