1

I have a UIRefreshControl added on my UITableView. It works fine when screen is loading for the first time. From the second time onwards, whenever I am calling beginRefreshing in viewWillAppear then the table view header gets stuck and also the refresh control is not showing. enter image description here

What could be the issue?

    override func ViewDidLoad(){

    refreshControl.addTarget(self, action: #selector(PlacesViewController.pullToRefresh), forControlEvents: .ValueChanged)
    tableView.addSubview(refreshControl)
    tableView.tableFooterView = UIView()
    self.tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 110, right: 0)

        FetchExtPlaceList([:],inBackground:inBackground)

}

func FetchExtPlaceList(pramrDisc:parameter,inBackground:Bool){

    if !inBackground{
        ActivityManager.ManageActivityView(self, action: .ActionAdd)
    }else if pageNumber == 1 {
        self.refreshControl.beginRefreshing()

    }


    WSRequest.SendRequest(WSMethod.POST, pramrDisc: pramrDisc, paramsString: nil, operation: WSOperation.FetchExtPlaceList, completionHandler: { response in

        if !inBackground{
            ActivityManager.ManageActivityView(self, action: .ActionRemove)
        }

        if let errorTitle = response.errorTitle {

            if let errorDescription = response.errorDescription {
                UIAlertController.ShowAlert(errorTitle, message: errorDescription)
            }

        }else if let wsError = response.wsError {

            if let infoMessage = wsError.infoMessage {
                UIAlertController.ShowAlert("", message: infoMessage)
            }else if let errorMessage = wsError.errorMessage {
                UIAlertController.ShowAlert("", message: errorMessage)
            }else if let error = wsError.error {
                UIAlertController.ShowAlert("", message: error.description)
            }

        }else{

            if let places = response.parsedObject as? [Place]{

                if self.pageNumber == 1 {
                    self.places.removeAll()
                }

                self.places.appendContentsOf(places)
                self.tableView.reloadData()
            }

        }

        if self.refreshControl.refreshing{
            self.refreshControl.endRefreshing()
        }
    })
}
Dattatray Deokar
  • 1,923
  • 2
  • 21
  • 31

1 Answers1

0

I got the issue. i was programatically calling trying to begin refreshing but i found on Here that i have to croll the table view by changing contentoffset.

Community
  • 1
  • 1
Dattatray Deokar
  • 1,923
  • 2
  • 21
  • 31