use*_*983 9 uibutton ios swift xcode6
我有一个按钮,按钮的标题是一个整数.
correctAnswer = randomNumber1 + randomNumber2
button1.setTitle("\(correctAnswer)", forState: UIControlState.Normal)
Run Code Online (Sandbox Code Playgroud)
我试图检查按钮的标题,所以将其转换为整数并在if语句中使用它,但无法使其工作.
button1.titleLabel?.text?.toInt()
if button1.titleLabel == correctAnswer { //most probably I am making a mistake here.
scoring() } else {
println(button1.titleLabel?.text!)
Run Code Online (Sandbox Code Playgroud)
我是新手,我甚至可能对我的方法有疑问,你的帮助将不胜感激.
| 归档时间: |
|
| 查看次数: |
10999 次 |
| 最近记录: |