@IBAction func nextTurn(sender: AnyObject) {
if numberOfTurn < (playersForPicker.count-1) {
numberOfTurn++
}else{
numberOfTurn = 0
}
titleForTwo.title = playersForPicker[numberOfTurn]
var lostPlayer = playersForPicker[numberOfTurn]
titleForTwo.title = playersForPicker[numberOfTurn]
playersForPicker.removeAtIndex(numberOfTurn)
playerPicker.reloadAllComponents()
playersForPicker.insert(lostPlayer, atIndex: numberOfTurn)
startButton.setTitle("Next Turn", forState: UIControlState())
}
playerPicker没有重新加载或更改,因此我需要有关如何在单击按钮时刷新或重新加载选取器视图的帮助。
答案 0 :(得分:0)
为什么要改变?您正在删除playersForPicker [numberOfTurn],但您将lostPlayer设置为相同的值,然后将其添加回阵列中的相同位置。阵列没有改变,所以你的选择器也不会改变。您正在重新加载选择器视图。如果您注释掉插入lostPlayer的行,您应该会看到该项目从选择器中消失。