Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
How to add Pull to refresh controller to scrollview?

Hi in my application I want to add Pull to refresh controller to scrollview. I write the following code but it don't getting any response.

When ever I scroll the view on that time add target method is not called.

@IBOutlet var scrool: UIScrollView!
var refreshControl = UIRefreshControl()

override func viewDidLoad() {
        super.viewDidLoad()
        // Add refresh control for the Home page scroll view.
        self.refreshControl.tintColor = UIColor.appcolor
        self.refreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh")
        self.refreshControl.addTarget(self, action: #selector(refresh(sender:)), for: UIControl.Event.valueChanged)
        self.scrool.isScrollEnabled = true
        self.scrool.alwaysBounceVertical = true
        scrool.addSubview(refreshControl)
    }
    @objc func refresh(sender:AnyObject) {
        // Code to refresh table view
        self.getHomePageApi()
        refreshControl.endRefreshing()

    }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Hi I resolved this issue when I write this code in viewwillappear() except viewdidload() function it will working fine.

var refreshControl:RefreshControl!    
override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        refreshControl = RefreshControl()
        refreshControl.addTarget(self, action: #selector(refresh), for: .valueChanged)
        scrool.refreshControl = refreshControl
    }

    @objc func refresh()
    {
        // Code to refresh table view
        refreshControl.endRefreshing()
        self.getHomePageApi()

    }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!