2
所以我想跟蹤用戶想要循環的方向。因此我有一個分段控件來選擇方向。Swift UISegmentedControl IBAction值不會改變
下面是代碼:
@IBOutlet weak var cycleSwitch: UISegmentedControl!
@IBAction func setCycleDirection(sender: AnyObject) {
switch cycleSwitch.selectedSegmentIndex
{
case 0:
cycleDirection = cycleSwitch.selectedSegmentIndex
case 1:
cycleDirection = cycleSwitch.selectedSegmentIndex
default:
break
}
println(cycleDirection)
}
,但沒有被打印出來。即使我評論一切,只是有一個println(「我在行動中」)不記錄。我也嘗試過這種情況,如cycleSwitch.selectedSegmentIndex == 0等都不起作用。
對於爲什麼值不會改變的任何建議或想法?
我已嘗試也。進行建議的更改並不能解決問題 – N3ur0n 2014-09-30 18:55:02
只是爲了驗證 - 您已確認「@ IBAction」已連接到您的分段控件的「Value Changed」操作,而不是其他內容? – andrewcbancroft 2014-09-30 19:28:21
是的,它的價值改變了。 – N3ur0n 2014-09-30 21:03:07