Swift 4 - UIRefreshControl on vertical UICollectionView lags

Multi tool use
For some reason, my pull to refresh is really hard to complete. What I mean by that, is that in order to pull-to-refresh I have to begin from the very top of my collection view and scroll down to the very bottom... sometimes I even have to use a second finger in order to scroll more to make it work!
Here's how I initialise the refresher:
private var refresher: UIRefreshControl!
override func viewDidLoad()
super.viewDidLoad()
// Do any additional setup after loading the view.
refresher = UIRefreshControl()
refresher.addTarget(self, action: #selector(self.requestRefreshContent), for: .valueChanged)
if #available(iOS 10.0, *)
schoolPostsCollectionView.refreshControl = refresher
else
schoolPostsCollectionView.addSubview(refresher)
refresher.beginRefreshing()
Here's how I call beginRefreshing()
:
private func getContentOfSchool()
someBackgroundServerCall()
// some code
...
DispatchQueue.main.async
self.refresher.endRefreshing()
self.schoolPostsCollectionView.reloadData()
Any idea why is this happening?
swift uirefreshcontrol
|
show 4 more comments
For some reason, my pull to refresh is really hard to complete. What I mean by that, is that in order to pull-to-refresh I have to begin from the very top of my collection view and scroll down to the very bottom... sometimes I even have to use a second finger in order to scroll more to make it work!
Here's how I initialise the refresher:
private var refresher: UIRefreshControl!
override func viewDidLoad()
super.viewDidLoad()
// Do any additional setup after loading the view.
refresher = UIRefreshControl()
refresher.addTarget(self, action: #selector(self.requestRefreshContent), for: .valueChanged)
if #available(iOS 10.0, *)
schoolPostsCollectionView.refreshControl = refresher
else
schoolPostsCollectionView.addSubview(refresher)
refresher.beginRefreshing()
Here's how I call beginRefreshing()
:
private func getContentOfSchool()
someBackgroundServerCall()
// some code
...
DispatchQueue.main.async
self.refresher.endRefreshing()
self.schoolPostsCollectionView.reloadData()
Any idea why is this happening?
swift uirefreshcontrol
What do you mean by never fully refreshed? does the functionrequestRefreshContent
not get called? Are you callingrefreshed.endRefreshing()
anywhere in your code?
– Broco
Nov 12 '18 at 12:53
check my updated question. And yes, I am callingrefresher.endRefreshing()
at some points...
– Sotiris Kaniras
Nov 12 '18 at 12:56
Why are you add subview in Collectionview.
– S.D
Nov 12 '18 at 13:08
@S.D because that's how it works...
– Sotiris Kaniras
Nov 12 '18 at 13:11
@SotirisKaniras Show full code...
– S.D
Nov 12 '18 at 13:14
|
show 4 more comments
For some reason, my pull to refresh is really hard to complete. What I mean by that, is that in order to pull-to-refresh I have to begin from the very top of my collection view and scroll down to the very bottom... sometimes I even have to use a second finger in order to scroll more to make it work!
Here's how I initialise the refresher:
private var refresher: UIRefreshControl!
override func viewDidLoad()
super.viewDidLoad()
// Do any additional setup after loading the view.
refresher = UIRefreshControl()
refresher.addTarget(self, action: #selector(self.requestRefreshContent), for: .valueChanged)
if #available(iOS 10.0, *)
schoolPostsCollectionView.refreshControl = refresher
else
schoolPostsCollectionView.addSubview(refresher)
refresher.beginRefreshing()
Here's how I call beginRefreshing()
:
private func getContentOfSchool()
someBackgroundServerCall()
// some code
...
DispatchQueue.main.async
self.refresher.endRefreshing()
self.schoolPostsCollectionView.reloadData()
Any idea why is this happening?
swift uirefreshcontrol
For some reason, my pull to refresh is really hard to complete. What I mean by that, is that in order to pull-to-refresh I have to begin from the very top of my collection view and scroll down to the very bottom... sometimes I even have to use a second finger in order to scroll more to make it work!
Here's how I initialise the refresher:
private var refresher: UIRefreshControl!
override func viewDidLoad()
super.viewDidLoad()
// Do any additional setup after loading the view.
refresher = UIRefreshControl()
refresher.addTarget(self, action: #selector(self.requestRefreshContent), for: .valueChanged)
if #available(iOS 10.0, *)
schoolPostsCollectionView.refreshControl = refresher
else
schoolPostsCollectionView.addSubview(refresher)
refresher.beginRefreshing()
Here's how I call beginRefreshing()
:
private func getContentOfSchool()
someBackgroundServerCall()
// some code
...
DispatchQueue.main.async
self.refresher.endRefreshing()
self.schoolPostsCollectionView.reloadData()
Any idea why is this happening?
swift uirefreshcontrol
swift uirefreshcontrol
edited Nov 12 '18 at 15:06
Sotiris Kaniras
asked Nov 12 '18 at 12:06
Sotiris KanirasSotiris Kaniras
328215
328215
What do you mean by never fully refreshed? does the functionrequestRefreshContent
not get called? Are you callingrefreshed.endRefreshing()
anywhere in your code?
– Broco
Nov 12 '18 at 12:53
check my updated question. And yes, I am callingrefresher.endRefreshing()
at some points...
– Sotiris Kaniras
Nov 12 '18 at 12:56
Why are you add subview in Collectionview.
– S.D
Nov 12 '18 at 13:08
@S.D because that's how it works...
– Sotiris Kaniras
Nov 12 '18 at 13:11
@SotirisKaniras Show full code...
– S.D
Nov 12 '18 at 13:14
|
show 4 more comments
What do you mean by never fully refreshed? does the functionrequestRefreshContent
not get called? Are you callingrefreshed.endRefreshing()
anywhere in your code?
– Broco
Nov 12 '18 at 12:53
check my updated question. And yes, I am callingrefresher.endRefreshing()
at some points...
– Sotiris Kaniras
Nov 12 '18 at 12:56
Why are you add subview in Collectionview.
– S.D
Nov 12 '18 at 13:08
@S.D because that's how it works...
– Sotiris Kaniras
Nov 12 '18 at 13:11
@SotirisKaniras Show full code...
– S.D
Nov 12 '18 at 13:14
What do you mean by never fully refreshed? does the function
requestRefreshContent
not get called? Are you calling refreshed.endRefreshing()
anywhere in your code?– Broco
Nov 12 '18 at 12:53
What do you mean by never fully refreshed? does the function
requestRefreshContent
not get called? Are you calling refreshed.endRefreshing()
anywhere in your code?– Broco
Nov 12 '18 at 12:53
check my updated question. And yes, I am calling
refresher.endRefreshing()
at some points...– Sotiris Kaniras
Nov 12 '18 at 12:56
check my updated question. And yes, I am calling
refresher.endRefreshing()
at some points...– Sotiris Kaniras
Nov 12 '18 at 12:56
Why are you add subview in Collectionview.
– S.D
Nov 12 '18 at 13:08
Why are you add subview in Collectionview.
– S.D
Nov 12 '18 at 13:08
@S.D because that's how it works...
– Sotiris Kaniras
Nov 12 '18 at 13:11
@S.D because that's how it works...
– Sotiris Kaniras
Nov 12 '18 at 13:11
@SotirisKaniras Show full code...
– S.D
Nov 12 '18 at 13:14
@SotirisKaniras Show full code...
– S.D
Nov 12 '18 at 13:14
|
show 4 more comments
1 Answer
1
active
oldest
votes
try this one....
refresher = UIRefreshControl()
refresher.attributedTitle = NSAttributedString(string: "Refreshing...", attributes: nil)
refresher.tintColor = UIColor.black
refresher.addTarget(self, action: #selector(self.requestRefreshContent), for: .valueChanged)
if #available(iOS 10.0, *)
schoolPostsCollectionView.refreshControl = refresher
else
schoolPostsCollectionView.backgroundView = refresher
Still nothing...
– Sotiris Kaniras
Nov 12 '18 at 13:11
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/3.0/"u003ecc by-sa 3.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%2f53261857%2fswift-4-uirefreshcontrol-on-vertical-uicollectionview-lags%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
try this one....
refresher = UIRefreshControl()
refresher.attributedTitle = NSAttributedString(string: "Refreshing...", attributes: nil)
refresher.tintColor = UIColor.black
refresher.addTarget(self, action: #selector(self.requestRefreshContent), for: .valueChanged)
if #available(iOS 10.0, *)
schoolPostsCollectionView.refreshControl = refresher
else
schoolPostsCollectionView.backgroundView = refresher
Still nothing...
– Sotiris Kaniras
Nov 12 '18 at 13:11
add a comment |
try this one....
refresher = UIRefreshControl()
refresher.attributedTitle = NSAttributedString(string: "Refreshing...", attributes: nil)
refresher.tintColor = UIColor.black
refresher.addTarget(self, action: #selector(self.requestRefreshContent), for: .valueChanged)
if #available(iOS 10.0, *)
schoolPostsCollectionView.refreshControl = refresher
else
schoolPostsCollectionView.backgroundView = refresher
Still nothing...
– Sotiris Kaniras
Nov 12 '18 at 13:11
add a comment |
try this one....
refresher = UIRefreshControl()
refresher.attributedTitle = NSAttributedString(string: "Refreshing...", attributes: nil)
refresher.tintColor = UIColor.black
refresher.addTarget(self, action: #selector(self.requestRefreshContent), for: .valueChanged)
if #available(iOS 10.0, *)
schoolPostsCollectionView.refreshControl = refresher
else
schoolPostsCollectionView.backgroundView = refresher
try this one....
refresher = UIRefreshControl()
refresher.attributedTitle = NSAttributedString(string: "Refreshing...", attributes: nil)
refresher.tintColor = UIColor.black
refresher.addTarget(self, action: #selector(self.requestRefreshContent), for: .valueChanged)
if #available(iOS 10.0, *)
schoolPostsCollectionView.refreshControl = refresher
else
schoolPostsCollectionView.backgroundView = refresher
answered Nov 12 '18 at 13:06


S.DS.D
1
1
Still nothing...
– Sotiris Kaniras
Nov 12 '18 at 13:11
add a comment |
Still nothing...
– Sotiris Kaniras
Nov 12 '18 at 13:11
Still nothing...
– Sotiris Kaniras
Nov 12 '18 at 13:11
Still nothing...
– Sotiris Kaniras
Nov 12 '18 at 13:11
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%2f53261857%2fswift-4-uirefreshcontrol-on-vertical-uicollectionview-lags%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
as LT bmxOO9kfu9vivZrssIiY,c3kpiG,H9rIMoELFbz5PNpeS62T oPk
What do you mean by never fully refreshed? does the function
requestRefreshContent
not get called? Are you callingrefreshed.endRefreshing()
anywhere in your code?– Broco
Nov 12 '18 at 12:53
check my updated question. And yes, I am calling
refresher.endRefreshing()
at some points...– Sotiris Kaniras
Nov 12 '18 at 12:56
Why are you add subview in Collectionview.
– S.D
Nov 12 '18 at 13:08
@S.D because that's how it works...
– Sotiris Kaniras
Nov 12 '18 at 13:11
@SotirisKaniras Show full code...
– S.D
Nov 12 '18 at 13:14