Question: I have created a UIRefreshcontrol in my tableviewcontroller as follows in the viewdidload method :

```
    refresh = [UIRefreshControl.alloc init];
    refresh.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"];
    [refresh addTarget:self action:@selector(refreshChatsTableView) forControlEvents:UIControlEventValueChanged];
    self.refreshControl = refresh;

```

the problem is that when I pull it down a little long , the table jitters up giving a pretty unpleasant UI experience. Can anyone please help ? This behavior is experienced only in the Landscape mode.

Here is my code :

```
-UIRefreshControl  *refresh;

    -(void)viewDidLoad{
        [super viewDidLoad];
         arr= [[NSArray    alloc]initWithObjects:@"A",@"B",@"C",@"D",@"E",@"A",@"B",@"C",@"D",@"E", nil];

        //refresh control
        refresh = [UIRefreshControl.alloc init];
        refresh.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to   Refresh"];
        [refresh addTarget:self action:@selector(refreshChatsTableView)  forControlEvents:UIControlEventValueChanged];
        self.refreshControl = refresh;
      }

    -(void)refreshChatsTableView{
        [refresh endRefreshing];
    }

    -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
        return 1;
    }

    -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
       return arr.count;
    }

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        static NSString *CellIdentifier = @"Cell";
        UITableViewCell *cell =[[UITableViewCell alloc]init];
        cell.textLabel.text = [arr objectAtIndex:indexPath.row ];

        return cell;
    }

```

Answer: 
My solution is similar to the accepted solution. The idea is to update your table view only after the view is at the right place. Therefore, we can add a variable to track if we need to update the view when the scroll view is completely bounced back (don't update it while decelerating).

Also, always update your table view before ending the refreshControl.

```
// The action function of refreshControl
@objc private func refresh() {
    DispatchQueue.global(qos: .utility).async {
        // Update data
        // ......

        // Update the table view
        DispatchQueue.main.async {
            if self.tableView.isDragging == false {
                self.tableView.reloadData()
                self.myRefreshControl.endRefreshing()
            } else {
                self.needEndRefreshing = true
            }
        }
    }
}

override func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
    if self.needEndRefreshing {
        self.tableView.reloadData()
        self.myRefreshControl.endRefreshing()
        self.needEndRefreshing = false
    }
}

```
**SWIFT 4:**

In ViewdidLoad()

someCollectionView or someTableView

```
someCollectionView.refreshControl?.addSubview(refreshControl)
someCollectionView.refreshControl?.sendSubview(toBack: refreshControl)

```

Worked perfectly for me.