2016-12-17 7 views
0

私はアイドルクリックゲーム/アプリケーションを作成しています。アップグレードを購入する方法は、表のセル内のボタンをクリックすることです。私が理解できないことは、ボタンのタイトルを設定する方法です(各ボタンに価格が表示されます)。タイプ '(UIButton) - >()'の値にtableViewのメンバ 'setTitle'がありません

: - 私はエラーを取得しようとすると、 私はXcodeの8.2、およびスウィフトを使用しています3.

カスタムセルコントローラ「タイプの値 『(UIButton)が>()』はメンバー 『のsetTitle』を持っていません」

@IBAction func upgradePurchase(_ sender: UIButton) { 
    if GlobalVariables.sharedManager.balance >= GlobalVariables.sharedManager.UpgradesPrice[GlobalVariables.sharedManager.UpgradesCurrent] { 

    } 
} 

テーブルビューコントローラ:ミスにより

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 

    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! CustomTableViewCell 

    let row = indexPath.row 

    let showPrice = "Buy: $\(GlobalVariables.sharedManager.UpgradesPrice[row])" 

    cell.upgradeIdentifier.text = GlobalVariables.sharedManager.UpgradesName[row] 

    cell.upgradeDescription.text = GlobalVariables.sharedManager.UpgradesDesc[row] 

    cell.upgradePurchase.setTitle("\(showPrice)", for: .Normal) 

    GlobalVariables.sharedManager.UpgradesCurrent = GlobalVariables.sharedManager.UpgradesPrice[row] 

    return cell 
} 
+1

どのラインでエラーが発生していますか?そしてあなたの 'CustomTableViewCell'クラスの宣言を投稿してください(具体的にはアウトレット) –

答えて

0

または誤ってあなたがいないUIButtonインスタンスへのボタンアクションのためのタイトルを設定しようとしています。ここでupgradePurchaseIBOutletではなくIBActionです。

タイトルをIBOutletに設定する必要があります。タイトルが設定されていない場合は、タイトルを設定してください。

cell.btnupgradePurchase.setTitle("\(showPrice)", for: .normal) 

注:スウィフト3ではそれは.normal.Normalではありません。

+0

それは働いた!私は今それを理解する! –

+0

@AidenR。ウェルカムメイト:) –

関連する問題