Swift 4 Refresh Control not smooth but always jumpPassing Data between View ControllersHow do I call Objective-C code from Swift?#pragma mark in Swift?How to use pull to refresh in Swift?Split a String into an array in Swift?How to detect tableView cell touched or clicked in swiftuse javascript data in tableView SwiftUITableView using UIRefreshControl either Won't Finish or has Flicker/Jump under iOS11TableView and cells not visible on UIControllerView Swift 4Swift vertical UICollectionView inside UITableView
How use custom order in folder on Windows 7 and 10
What exactly did this mechanic sabotage on the American Airlines 737, and how dangerous was it?
Meaning of 'ran' in German?
Was there a trial by combat between a man and a dog in medieval France?
Strange Sticky Substance on Digital Camera
How can this Stack Exchange site have an animated favicon?
How do I deal with too many NPCs in my campaign?
Cut a cake into 3 equal portions with only a knife
What do you do if you have developments on your paper during the long peer review process?
What is the meaning of word 'crack' in chapter 33 of A Game of Thrones?
Resolving moral conflict
Is there a way to hide HTML source code yet keeping it effective?
Is this a Sherman, and if so what model?
Are there any adverse impacts if I keep WiFi router on all time?
Designing a time thief proof safe
Can I take NEW (still in their boxes) PC PARTS in my checked in luggage?
Late 1970's and 6502 chip facilities for operating systems
Does Fires of Invention allow adventure instant and sorceries to be played for free?
Is it impolite to ask for an in-flight catalogue with no intention of buying?
Is it really necessary to have a four hour meeting in Sprint planning?
What benefits does the Power Word Kill spell have?
Can the U.S. president make military decisions without consulting anyone?
How to manage expenditure when billing cycles and paycheck cycles are not aligned?
Is it right to extend flaps only in the white arc?
Swift 4 Refresh Control not smooth but always jump
Passing Data between View ControllersHow do I call Objective-C code from Swift?#pragma mark in Swift?How to use pull to refresh in Swift?Split a String into an array in Swift?How to detect tableView cell touched or clicked in swiftuse javascript data in tableView SwiftUITableView using UIRefreshControl either Won't Finish or has Flicker/Jump under iOS11TableView and cells not visible on UIControllerView Swift 4Swift vertical UICollectionView inside UITableView
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a UIViewController, inside which there is a tableView. I added a RefreshControl. But when I pull, it always jumps for some times, which is not smooth and continuous at all.
I'm using Swift 4 and Xcode 10.1.
class ItemsController: UIViewController, UITableViewDelegate, UITableViewDataSource, UITextViewDelegate, ItemCellDelegate
......
lazy var refreshControl: UIRefreshControl =
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action:
#selector(handleRefresh(_:)),
for: UIControl.Event.valueChanged)
refreshControl.tintColor = UIColor.lightGray
return refreshControl
()
......
override func viewDidLoad()
// Refresh
self.tableView.refreshControl = self.refreshControl
......
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
loadData()
self.tableView.reloadData()
refreshControl.endRefreshing()
......
ios swift uitableview uirefreshcontrol
add a comment
|
I have a UIViewController, inside which there is a tableView. I added a RefreshControl. But when I pull, it always jumps for some times, which is not smooth and continuous at all.
I'm using Swift 4 and Xcode 10.1.
class ItemsController: UIViewController, UITableViewDelegate, UITableViewDataSource, UITextViewDelegate, ItemCellDelegate
......
lazy var refreshControl: UIRefreshControl =
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action:
#selector(handleRefresh(_:)),
for: UIControl.Event.valueChanged)
refreshControl.tintColor = UIColor.lightGray
return refreshControl
()
......
override func viewDidLoad()
// Refresh
self.tableView.refreshControl = self.refreshControl
......
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
loadData()
self.tableView.reloadData()
refreshControl.endRefreshing()
......
ios swift uitableview uirefreshcontrol
add a comment
|
I have a UIViewController, inside which there is a tableView. I added a RefreshControl. But when I pull, it always jumps for some times, which is not smooth and continuous at all.
I'm using Swift 4 and Xcode 10.1.
class ItemsController: UIViewController, UITableViewDelegate, UITableViewDataSource, UITextViewDelegate, ItemCellDelegate
......
lazy var refreshControl: UIRefreshControl =
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action:
#selector(handleRefresh(_:)),
for: UIControl.Event.valueChanged)
refreshControl.tintColor = UIColor.lightGray
return refreshControl
()
......
override func viewDidLoad()
// Refresh
self.tableView.refreshControl = self.refreshControl
......
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
loadData()
self.tableView.reloadData()
refreshControl.endRefreshing()
......
ios swift uitableview uirefreshcontrol
I have a UIViewController, inside which there is a tableView. I added a RefreshControl. But when I pull, it always jumps for some times, which is not smooth and continuous at all.
I'm using Swift 4 and Xcode 10.1.
class ItemsController: UIViewController, UITableViewDelegate, UITableViewDataSource, UITextViewDelegate, ItemCellDelegate
......
lazy var refreshControl: UIRefreshControl =
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action:
#selector(handleRefresh(_:)),
for: UIControl.Event.valueChanged)
refreshControl.tintColor = UIColor.lightGray
return refreshControl
()
......
override func viewDidLoad()
// Refresh
self.tableView.refreshControl = self.refreshControl
......
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
loadData()
self.tableView.reloadData()
refreshControl.endRefreshing()
......
ios swift uitableview uirefreshcontrol
ios swift uitableview uirefreshcontrol
edited Mar 28 at 16:59
Bhaumik
9131 gold badge6 silver badges17 bronze badges
9131 gold badge6 silver badges17 bronze badges
asked Mar 28 at 16:39
Victor LiVictor Li
306 bronze badges
306 bronze badges
add a comment
|
add a comment
|
4 Answers
4
active
oldest
votes
I also faced that kind of problem. You can use this approach below:
Change your handleRefresh method like this:
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
if !tableView.isDragging
refresh() // refresh is another method for your reloading jobs
Add refresh method.
func refresh()
self.refreshControl.endRefreshing()
self.tableView.reloadData()Lastly you need to implement scrollViewDidEndDragging. If you've pulled down far enough, the refreshControl will be refreshing, so call refresh. Otherwise, you either haven't pulled down far enough, you were dragging on a different part of the table, or you dragged so quickly that the refreshControl ValueChanged event has yet to fire, and it will refresh the table there.
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
if refreshControl.isRefreshing == true
refresh()
add a comment
|
Is loadData()
asynchronous? because if so it should have a completion handler and
tableView.reloadData()
refreshControl.endRefreshing()
should be done (on the main thread) from there. Otherwise what is happening is the user pulls down and you instantly update the tableView and stop the refresh control, so thats why you have no animation.
So how do I do these after loadData() is completed?
– Victor Li
Mar 28 at 18:26
add a comment
|
try
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
loadData()
self.tableView.reloadData()
DispatchQueue.main.async
//DispatchQueue.main.asyncAfter(deadline: .now + 0.2) // or this one with
//short delay
refreshControl.endRefreshing()
Thank you! This makes the animation become smoother, but there is still a little bit of jumping.
– Victor Li
Mar 28 at 18:43
add a comment
|
I just solved this problem by doing this:
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
refreshControl.endRefreshing()
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
loadData()
Pretty simple. Now the animation is much better.
The tableView.reloadData(), which is inside of loadData(), is getting the animation less smooth. So I make it do after the user releases from dragging.
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55402810%2fswift-4-refresh-control-not-smooth-but-always-jump%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
I also faced that kind of problem. You can use this approach below:
Change your handleRefresh method like this:
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
if !tableView.isDragging
refresh() // refresh is another method for your reloading jobs
Add refresh method.
func refresh()
self.refreshControl.endRefreshing()
self.tableView.reloadData()Lastly you need to implement scrollViewDidEndDragging. If you've pulled down far enough, the refreshControl will be refreshing, so call refresh. Otherwise, you either haven't pulled down far enough, you were dragging on a different part of the table, or you dragged so quickly that the refreshControl ValueChanged event has yet to fire, and it will refresh the table there.
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
if refreshControl.isRefreshing == true
refresh()
add a comment
|
I also faced that kind of problem. You can use this approach below:
Change your handleRefresh method like this:
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
if !tableView.isDragging
refresh() // refresh is another method for your reloading jobs
Add refresh method.
func refresh()
self.refreshControl.endRefreshing()
self.tableView.reloadData()Lastly you need to implement scrollViewDidEndDragging. If you've pulled down far enough, the refreshControl will be refreshing, so call refresh. Otherwise, you either haven't pulled down far enough, you were dragging on a different part of the table, or you dragged so quickly that the refreshControl ValueChanged event has yet to fire, and it will refresh the table there.
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
if refreshControl.isRefreshing == true
refresh()
add a comment
|
I also faced that kind of problem. You can use this approach below:
Change your handleRefresh method like this:
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
if !tableView.isDragging
refresh() // refresh is another method for your reloading jobs
Add refresh method.
func refresh()
self.refreshControl.endRefreshing()
self.tableView.reloadData()Lastly you need to implement scrollViewDidEndDragging. If you've pulled down far enough, the refreshControl will be refreshing, so call refresh. Otherwise, you either haven't pulled down far enough, you were dragging on a different part of the table, or you dragged so quickly that the refreshControl ValueChanged event has yet to fire, and it will refresh the table there.
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
if refreshControl.isRefreshing == true
refresh()
I also faced that kind of problem. You can use this approach below:
Change your handleRefresh method like this:
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
if !tableView.isDragging
refresh() // refresh is another method for your reloading jobs
Add refresh method.
func refresh()
self.refreshControl.endRefreshing()
self.tableView.reloadData()Lastly you need to implement scrollViewDidEndDragging. If you've pulled down far enough, the refreshControl will be refreshing, so call refresh. Otherwise, you either haven't pulled down far enough, you were dragging on a different part of the table, or you dragged so quickly that the refreshControl ValueChanged event has yet to fire, and it will refresh the table there.
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
if refreshControl.isRefreshing == true
refresh()
answered Mar 28 at 18:52
Imrul KayesImrul Kayes
4961 gold badge6 silver badges15 bronze badges
4961 gold badge6 silver badges15 bronze badges
add a comment
|
add a comment
|
Is loadData()
asynchronous? because if so it should have a completion handler and
tableView.reloadData()
refreshControl.endRefreshing()
should be done (on the main thread) from there. Otherwise what is happening is the user pulls down and you instantly update the tableView and stop the refresh control, so thats why you have no animation.
So how do I do these after loadData() is completed?
– Victor Li
Mar 28 at 18:26
add a comment
|
Is loadData()
asynchronous? because if so it should have a completion handler and
tableView.reloadData()
refreshControl.endRefreshing()
should be done (on the main thread) from there. Otherwise what is happening is the user pulls down and you instantly update the tableView and stop the refresh control, so thats why you have no animation.
So how do I do these after loadData() is completed?
– Victor Li
Mar 28 at 18:26
add a comment
|
Is loadData()
asynchronous? because if so it should have a completion handler and
tableView.reloadData()
refreshControl.endRefreshing()
should be done (on the main thread) from there. Otherwise what is happening is the user pulls down and you instantly update the tableView and stop the refresh control, so thats why you have no animation.
Is loadData()
asynchronous? because if so it should have a completion handler and
tableView.reloadData()
refreshControl.endRefreshing()
should be done (on the main thread) from there. Otherwise what is happening is the user pulls down and you instantly update the tableView and stop the refresh control, so thats why you have no animation.
answered Mar 28 at 17:03
Josh HomannJosh Homann
9,8442 gold badges16 silver badges24 bronze badges
9,8442 gold badges16 silver badges24 bronze badges
So how do I do these after loadData() is completed?
– Victor Li
Mar 28 at 18:26
add a comment
|
So how do I do these after loadData() is completed?
– Victor Li
Mar 28 at 18:26
So how do I do these after loadData() is completed?
– Victor Li
Mar 28 at 18:26
So how do I do these after loadData() is completed?
– Victor Li
Mar 28 at 18:26
add a comment
|
try
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
loadData()
self.tableView.reloadData()
DispatchQueue.main.async
//DispatchQueue.main.asyncAfter(deadline: .now + 0.2) // or this one with
//short delay
refreshControl.endRefreshing()
Thank you! This makes the animation become smoother, but there is still a little bit of jumping.
– Victor Li
Mar 28 at 18:43
add a comment
|
try
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
loadData()
self.tableView.reloadData()
DispatchQueue.main.async
//DispatchQueue.main.asyncAfter(deadline: .now + 0.2) // or this one with
//short delay
refreshControl.endRefreshing()
Thank you! This makes the animation become smoother, but there is still a little bit of jumping.
– Victor Li
Mar 28 at 18:43
add a comment
|
try
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
loadData()
self.tableView.reloadData()
DispatchQueue.main.async
//DispatchQueue.main.asyncAfter(deadline: .now + 0.2) // or this one with
//short delay
refreshControl.endRefreshing()
try
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
loadData()
self.tableView.reloadData()
DispatchQueue.main.async
//DispatchQueue.main.asyncAfter(deadline: .now + 0.2) // or this one with
//short delay
refreshControl.endRefreshing()
answered Mar 28 at 18:30
Hen ShabatHen Shabat
12410 bronze badges
12410 bronze badges
Thank you! This makes the animation become smoother, but there is still a little bit of jumping.
– Victor Li
Mar 28 at 18:43
add a comment
|
Thank you! This makes the animation become smoother, but there is still a little bit of jumping.
– Victor Li
Mar 28 at 18:43
Thank you! This makes the animation become smoother, but there is still a little bit of jumping.
– Victor Li
Mar 28 at 18:43
Thank you! This makes the animation become smoother, but there is still a little bit of jumping.
– Victor Li
Mar 28 at 18:43
add a comment
|
I just solved this problem by doing this:
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
refreshControl.endRefreshing()
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
loadData()
Pretty simple. Now the animation is much better.
The tableView.reloadData(), which is inside of loadData(), is getting the animation less smooth. So I make it do after the user releases from dragging.
add a comment
|
I just solved this problem by doing this:
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
refreshControl.endRefreshing()
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
loadData()
Pretty simple. Now the animation is much better.
The tableView.reloadData(), which is inside of loadData(), is getting the animation less smooth. So I make it do after the user releases from dragging.
add a comment
|
I just solved this problem by doing this:
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
refreshControl.endRefreshing()
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
loadData()
Pretty simple. Now the animation is much better.
The tableView.reloadData(), which is inside of loadData(), is getting the animation less smooth. So I make it do after the user releases from dragging.
I just solved this problem by doing this:
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
refreshControl.endRefreshing()
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
loadData()
Pretty simple. Now the animation is much better.
The tableView.reloadData(), which is inside of loadData(), is getting the animation less smooth. So I make it do after the user releases from dragging.
answered Mar 28 at 19:20
Victor LiVictor Li
306 bronze badges
306 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55402810%2fswift-4-refresh-control-not-smooth-but-always-jump%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown