0 uirefreshcontrol swift ios10
我在iOS 10的swift 3中向滚动视图添加了refreshControl,但是未调用添加的函数。
这是我的代码。
let rc = UIRefreshControl()
rc.addTarget(self, action: #selector(refresh), for: UIControlEvents.valueChanged)
if #available(iOS 10.0, *) {
scrollView.refreshControl = rc
}
...
@objc func refresh(_ sender: AnyObject) {
let response = serverHelper.send(word: JSONParser.getAllGamesForPlayer(player: localPlayer))
let games = JSONParser.parseToArrayDic(string: response)
print("All games \(games)")
addAllGameButtons(games: games)
sender.endRefreshing()
}
Run Code Online (Sandbox Code Playgroud)
I want that the refreshContol is calling the refresh function.
But the function is never called.
What I'm doing wrong here?
EDIT
The refreshControl is working, but the problem is, that I have to scroll down to the end of the screen so that the function gets called. My scrollView has a high of 1200 px. Anyone who knows how to solve this?
当我的视图控制器size: freeform在故事板上的像素为1500px 时,我遇到了这个错误。当我将其更改为固定大小并推断时,刷新开始按预期工作。
看起来像是苹果方面的错误,刷新控件,值更改距离是在从Xib / Storyboard加载视图时设置的,但在为设备布局时未更新。