12

When I slowly pull down to refresh, I see the UIActivityIndicator circle slowly get more complete before it starts the refresh. Just before the circle is complete and the refresh actually triggers, the content jumps/jerks down and then the circle starts spinning. I only notice this when I pull down slowly.

I'm using the pull to refresh inside a scroll view called mainSV

    self.refresh = [[UIRefreshControl alloc] init];
    [self.refresh addTarget:self action:@selector(handleRefresh) forControlEvents:UIControlEventValueChanged];
    [self.mainSV addSubview:self.refresh];

Why does this jump/jerk happen?

Sonia Casas
  • 801
  • 9
  • 18
tcox
  • 544
  • 8
  • 19

4 Answers4

8

It's probably a bug in iOS. Your setup is correct, and I see the same thing in my app.

Austin
  • 5,625
  • 1
  • 29
  • 43
4

I suspect the jump/jerk is due to a "double" action.

There was a change to refresh implementation following the release of Xcode 5.

As such, the requirement to set a target action as described in the Apple Documentation is no longer necessary.

As you are using a Storyboard, in your Interface Builder / Storyboard file, select your storyboard scene (table view controller).

In the attributes inspector, under the subheading Table View Controller, select the item "Refreshing" and change the setting from "Disabled" to "Enabled".

Attribute Inspector for Table View Controller

Delete or comment out the three lines of code you have included in your question. (When it was required, i.e. prior to Xcode 5, I placed this code in my viewDidLoad TVC lifecycle method.)

If not automatically inserted into your code, then add this as either a public or private IBAction...

- (IBAction)refresh:(UIRefreshControl *)sender;

and wire to your scene / table view controller to the Sent Event "Value Changed".

Visual representation of outlet connection

Ensure your refresh action is properly configured...

- (IBAction)refresh:(UIRefreshControl *)sender {
    [self.refreshControl beginRefreshing];

    //  Refresh code for your TVC

    [self.refreshControl endRefreshing];
}

Note that no property is required to be set for refreshControl - I suspect there is a trigger to automatically synthesise this when you choose the setting Refreshing [Enabled] in your TVC attributes in the storyboard.

If you need to call the refresh from in your code, use this line...

[self refresh:self.refreshControl];
andrewbuilder
  • 3,629
  • 2
  • 24
  • 46
  • 4
    If I understand it right - this works only for a subclass of `UITableViewController`? But not for `UITableView` inside of `UIViewController`? – Roman Jul 07 '14 at 13:04
  • 1
    I still get a jump/jerk when implementing this way :( – lostintranslation Apr 28 '15 at 21:42
  • @oyatek per [Apple docs](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIRefreshControl_class/) you are correct, the refresh control is specifically designed for use in a table view that's managed by a table view controller. Not sure where the second option is mentioned in the question though? – andrewbuilder Apr 28 '15 at 21:51
  • @lostintranslation you may need to add some more code to your question... for example to explain the code that is running when you trigger the refresh? – andrewbuilder Apr 28 '15 at 21:54
  • Also another question... Does the behaviour repeat when you pull down at normally? – andrewbuilder Apr 28 '15 at 22:02
  • Actually only happens the first pull. I have text set. And text is very close to spinner initially as I pull down. As I get to the bottom the jump happens when the text correctly spaces itself from the spinner. Even time I pull after the first time it seems to behave correctly. – lostintranslation Apr 29 '15 at 01:52
1

I would need to see the rest of your code (or at least the scrolling + refreshing methods) to diagnose the problem.

Here's our tutorial for implementing custom pull to refresh controls in objective-c and swift. If you follow this tutorial you shouldn't see any jumping or jerking.

http://www.jackrabbitmobile.com/design/ios-custom-pull-to-refresh-control/

Hope it helps!

0

Old questions but if someone still has this issue and you are using NavigationController just make your NavigationBar "Translucent".

enter image description here

Using non translucent NavigationBar causes the tableview to jump slightly when UIControlEventValueChanged is fired for some reason.

XCode 10.1

jrswgtr
  • 2,287
  • 8
  • 23
  • 49