但是,当我传递UIProgressView的标记值时,当我在方法中从发件人检索它时,它总是显示为0。
伪代码
var c : Int = 0
func randomFunction () {
c++
// some settup for UIButton and UIProgressView
myProgressView.tag = c
myButton.addTarget(self, action: "holding:", forControlEvents: .TouchDown)
}
func holding (sender:UIButton!) {
print(sender.tag)
}
答案 0 :(得分:1)
请注意,发件人是按钮而非myProgressView,因此发件人的标签myButton始终为零。
如果您想获取myProgressView的标签,请按以下方式更改您的代码:
func holding (sender:UIButton!) {
print(myProgressView.tag)
}