0
您好我一直在關注上的Xcode 7.2一些教程,但是這對於那些迅速1.2 我認爲它SWIFT 2.1 他使用的UITextField與spriteKit 但此行會導致錯誤 我已經用Google搜索,但找不到任何幫助 所以認爲這是幫助歡呼添加到的UITextField精靈套件
self.view!.addSubview(TextInput!)
整個代碼是
進口SpriteKit
的地方class GameScene: SKScene { var TextInput:UITextField? override func didMoveToView(view: SKView) { let myLabel = SKLabelNode(fontNamed:"Chalkduster") myLabel.text = "" myLabel.fontSize = 15 myLabel.position = CGPoint(x:CGRectGetMidX(self.frame), y:CGRectGetMidY(self.frame)) self.addChild(myLabel) TextInput?.frame = CGRect(x: 200, y: 300, width: 100, height: 40) self.view!.addSubview(TextInput!) TextInput?.backgroundColor = UIColor.whiteColor() } override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { /* Called when a touch begins */ for touch in touches { let location = touch.locationInNode(self) } } override func update(currentTime: CFTimeInterval) { /* Called before each frame is rendered */ } }
不是非常有幫助的,是嗎?我嘗試了同樣的事情。我的'TextInput'被初始化。但沒有添加視圖,或者我無法在iPhone 5s上看到它。 – Boggartfly