相关疑难解决方法(0)

UIScrollView在滚动时暂停NSTimer

我有UIScrollView一系列快速更新数字的标签(每隔0.06秒).然而,当滚动视图移动时,NSTimer暂停并且直到滚动和弹性动画完成之后才暂停.

NSTimer无论滚动视图的状态如何,我如何避免这种情况并进行运行?

xcode uiscrollview nstimer ios

7
推荐指数
1
解决办法
3730
查看次数

NSTimer太慢了

我见过类似的多个问题; 但是,他们都没有解决我的问题.我的计时器太慢了.我只使用0.01秒的间隔.这是我的代码:

@IBOutlet var timerLabel: UILabel!

var miliseconds = 0
var seconds = 0

func updateLabel() {
    if miliseconds == 0 {
        timerLabel.text = "\(seconds).00"
    } else if miliseconds < 10 {
        timerLabel.text = "\(seconds).0\(miliseconds)"
    } else {
        timerLabel.text = "\(seconds).\(miliseconds)"
    }
}

var timer = NSTimer()

func updateTime() {

    miliseconds++
    if miliseconds == 100 {
        miliseconds = 0
        seconds++
    }
    updateLabel()
}

override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
    if timerState == 1 {
        timer = …
Run Code Online (Sandbox Code Playgroud)

time nstimer ios swift

-1
推荐指数
1
解决办法
731
查看次数

标签 统计

ios ×2

nstimer ×2

swift ×1

time ×1

uiscrollview ×1

xcode ×1