Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 错误:“找不到支持键盘类型4的键盘平面”_Ios_Swift - Fatal编程技术网

Ios 错误:“找不到支持键盘类型4的键盘平面”

Ios 错误:“找不到支持键盘类型4的键盘平面”,ios,swift,Ios,Swift,在这一行代码中: 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_D

在这一行代码中:

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.
    }

这只是一个警告,说明键盘类型不存在,很可能已弃用

另一方面,这是一个错误,很可能是因为userGuessTextField.text为零,无法进行比较


这里的解决方案是检查userGuessTextField.text是否有值,并且正如beyowulf所建议的,您应该将userGuessTextField连接到它的故事板元素。

Your@IBOutlet var userGuessTextField:UITextField!未连接到IB中的文本字段。请从其旁边的灰色空圆圈拖动到要成为UserGuestTextField的文本字段。
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)