在按下按钮之前如何使IBAction无效?

问题描述 投票:-1回答:1

我正在制作一个快速的程序,当按下按钮时会滚动,但在此之前,它询问他们是否相信他们会滚动蛇眼,是或否。

我想知道是否有可能当点击是或否时,它会等待用户点击滚动按钮然后根据它执行响应?我很困惑如何添加IBAction按下。

我试图将yes按钮IBAction添加到滚动按钮IBAction中,并且最终出现了许多错误。

@IBAction func yesButton(_ sender: Any) {    
    if(diceImageView1.image == diceImageView2.image){
        resultText()
    } else {
        lossText()
        //functions changes label to message telling user if they rolled  snake eyes or not 
    }
}

我希望用户能够点击响应,然后必须点击滚动按钮才能更改标签。

swift ibaction
1个回答
0
投票

介绍一个UIAlertViewController。然后根据按钮执行逻辑。

见指南

https://medium.com/ios-os-x-development/how-to-use-uialertcontroller-in-swift-70143d7fbede

© www.soinside.com 2019 - 2024. All rights reserved.