Swift 4 - UIRefreshControl on vertical UICollectionView lags










0















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?










share|improve this question
























  • 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












  • 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















0















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?










share|improve this question
























  • 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












  • 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













0












0








0








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?










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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












  • 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











  • 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
















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












1 Answer
1






active

oldest

votes


















0














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






share|improve this answer























  • Still nothing...

    – Sotiris Kaniras
    Nov 12 '18 at 13:11










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



);













draft saved

draft discarded


















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









0














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






share|improve this answer























  • Still nothing...

    – Sotiris Kaniras
    Nov 12 '18 at 13:11















0














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






share|improve this answer























  • Still nothing...

    – Sotiris Kaniras
    Nov 12 '18 at 13:11













0












0








0







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






share|improve this answer













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







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 '18 at 13:06









S.DS.D

1




1












  • 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





Still nothing...

– Sotiris Kaniras
Nov 12 '18 at 13:11

















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

Syphilis

Darth Vader #20