【发布时间】:2020-12-15 02:30:23
【问题描述】:
我想在 swift 中使用计时器旋转所有 UIPickerView 组件,如彩票轮。我在UIPickerView 中有一个 3 组件,想同时旋转所有组件。我正在使用下面的代码来旋转UIPickerView 中的组件:
let timer = Timer.scheduledTimer(timeInterval: 2.0, target: self, selector: #selector(scrollRandomly), userInfo: nil, repeats: true);
@objc func scrollRandomly() {
let row:Int = Int(arc4random() % 9);
let row1:Int = Int(arc4random() % 9);
let row2:Int = Int(arc4random() % 9);
pickerView.selectRow(row, inComponent: 0, animated: true)
pickerView.selectRow(row1, inComponent: 1, animated: true)
pickerView.selectRow(row2, inComponent: 2, animated: true)
}
谢谢, 拉沙布
【问题讨论】:
-
那么...你有什么问题?
-
@AndreasOetjen 参考链接:github.com/MaorS/iOS-Proj-CasinoGame
-
再一次,这不是一个问题。您面临什么问题?
-
@AndreasOetjen 我无法在 10 秒内旋转组件,我该如何以编程方式旋转组件
标签: ios swift iphone xcode swift3