我工作的一個應用程序,並請找我下面的代碼:按鈕無效(SWIFT)
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var NameTextLabel: UILabel!
@IBOutlet weak var ExplainTextLabel: UILabel!
@IBOutlet weak var PriceTextLabel: UILabel!
@IBOutlet weak var FeaturesTextLabel: UILabel!
let Features = ["Features Include: Siri acts as a musicologist, Advanced searches..., Works with Apple Music, etc", " Feautres Include: Up to 18 Cores, Thunderbolt 3, 5k Display, etc",
"Feautres Include: AR technology, I messages wont take up storage, A redesinged appstore, etc", "New Faces, Siri Face, Better Pairing Process"]
let Explain = ["Apple Smart Speaker", "Most Powerfull Mac", "The New OS", "Watch OS4"]
let Price = ["At $349", "At $4999", "Free", "Free"]
let Name = ["Homepod", "iMac Pro", "iOS 11", "Watch OS4"]
@IBAction func MoreDidTap(sender: AnyObject) {
let randomNumber = Int(arc4random()) % 4
let NewName = Name [randomNumber]
let NewExplain = Explain [randomNumber]
let NewPrice = Price [randomNumber]
let NewFeatures = Features [randomNumber]
NameTextLabel.text = NewName
ExplainTextLabel.text = NewExplain
PriceTextLabel.text = NewPrice
FeaturesTextLabel.text = NewFeatures
}
}
當我運行在模擬器的應用和我發現,雖然點擊按鈕然後沒有什麼會改變。如果有人知道,那麼請幫助我。
你有沒有在'MoreDidTap'中的代碼中放置一個斷點?它會被叫嗎? –
標籤和按鈕事件綁定是否正確或不檢查一次? –