Monday 28 September 2015

How To Use Refresh Controll on Refresh data PullToRefresh In Ios/Iphone

=> First Use Declared IBoutlet Of RefreshControll:-

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    //[tblViewData setEditing:YES animated:YES];
   
    refreshControl = [[UIRefreshControl alloc] init];
    [refreshControl setTintColor:[UIColor orangeColor]];
    [refreshControl setAttributedTitle:[[NSAttributedString alloc] initWithString:@"Pull down to refresh..."]];
    [refreshControl addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged];
   
    [tblViewData addSubview:refreshControl];
}
==> Uisng This Method refresh Some Data Of UITableView:-

- (void)refreshData
{
    [refreshControl setAttributedTitle:[[NSAttributedString alloc] initWithString:@"Please wait..."]];
   
    [self performSelector:@selector(stopRefreshControl) withObject:nil afterDelay:5.0];
}

- (void)stopRefreshControl
{
    if(refreshControl.isRefreshing)
    {
        [refreshControl endRefreshing];
        [refreshControl setAttributedTitle:[[NSAttributedString alloc] initWithString:@"Pull down to refresh..."]];
    }
}