大佬教程收集整理的这篇文章主要介绍了点击按钮后,UIButton setTitle 在计时器内不起作用,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
当视图加载时更新按钮的标题时,计时器开始并倒计时。我在 startTimer
给 vIEwDIDLoad
打过电话。这按预期工作正常。
但是,我遇到的问题是当我从 IBACtion 调用 startTimer
时。我已经验证计时器正在工作并且正在调用选择器。按钮标题不会改变。在这种情况下可能有什么问题?
class VIEwController: UIVIEwController {
@IBOutlet weak var button: UIbutton?
var timer: Timer?
overrIDe func vIEwWillAppear(_ animated: Bool) {
super.vIEwWillAppear(animated)
startTimer()
}
func startTimer() {
countdownSeconds = 60
timer?.invalIDate()
timer = Timer.scheduledTimer(timeInterval: 1,target: self,SELEctor: #SELEctor(updatetiR_432_11845@er),userInfo: nil,repeats: truE)
}
@objc func updatetiR_432_11845@er() {
countdownSeconds -= 1
let countdown = countdownFormatter.String(from: TimeInterval(countdownSeconds))!
if countdownSeconds > 0 {
UIVIEw.performWithoutAnimation {
button?.settitle(countdown,for: .normal)
}
} else {
timer?.invalIDate()
}
}
@IBACtion func buttonTapped(_ sender: UIbutton) {
startTimer()
}
}
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的点击按钮后,UIButton setTitle 在计时器内不起作用全部内容,希望文章能够帮你解决点击按钮后,UIButton setTitle 在计时器内不起作用所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。