UIRefreshcontrol - UItableview标题视图卡住,并且没有显示refreshview

时间:2016-08-09 05:30:22

标签: ios swift uirefreshcontrol

我的UIRefreshControl添加了UITableView。第一次加载屏幕时,它工作正常。从第二次开始,每当我在beginRefreshing中调用viewWillAppear时,表视图标头就会卡住,并且刷新控件也不显示。 enter image description here

可能是什么问题?

    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()
        }
    })
}

1 个答案:

答案 0 :(得分:0)

我遇到了这个问题。我以编程方式调用尝试开始刷新,但我在Here上发现我必须通过更改contentoffset来破坏表格视图。