Pull To Refresh Jump in iOS

前端 未结 4 1928
你的背包
你的背包 2021-02-07 22:00

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 refre

4条回答
  •  南笙
    南笙 (楼主)
    2021-02-07 22:24

    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];
    

提交回复
热议问题