簡體   English   中英

錯誤:“找不到支持鍵盤類型 4 的鍵盤”

[英]Error: "Can't find keyplane that supports type 4 for keyboard"

在這行代碼中:

if diceRoll == userGuessTextField.text {

我收到此錯誤:

2016-02-04 18:38:34.756 How Many Fingers[2972:158461] Can't find keyplane that supports type 4 for keyboard iPhone-PortraitChoco-NumberPad; using 1336863583_PortraitChoco_iPhone-Simple-Pad_Default
fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb) 

這是我的代碼:

import UIKit

class ViewController: UIViewController {

    @IBOutlet var userGuessTextField: UITextField!

    @IBOutlet var resultLabel: UILabel!

    @IBAction func guess(sender: AnyObject) {

    let diceRoll = String(arc4random_uniform(6))


        if diceRoll == userGuessTextField.text {


            resultLabel.text = "You're right!"
        }
        else {

            resultLabel.text = "Wrong! It was a " + diceRoll
        }
    }


    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

在此處輸入圖片說明

這只是警告鍵盤類型不存在,很可能已被棄用。

 2016-02-04 18:38:34.756 How Many Fingers[2972:158461] Can't find keyplane that supports type 4 for keyboard iPhone-PortraitChoco-NumberPad; using 1336863583_PortraitChoco_iPhone-Simple-Pad_Default

另一方面,這是一個錯誤,很可能是由於userGuessTextField.textnil並且無法進行比較。

 fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)

您在這里的解決方案是檢查userGuessTextField.text是否具有值,並且正如beyowulf建議的那樣,您應該將userGuessTextField連接到它的故事板元素。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM