0

I am trying to add one UITextField to SKScene subclass, I referred this url:

Adding textfield to SKScene

Here they are doing it in objective c.

I tried to do the similar thing in swift, by using below code:

let playerNameTextField = UITextField(frame: CGRectMake(50, 150, 50, 10))

playerNameTextField.center = CGPointMake(self.size.width / 2, self.size.height / 2)
playerNameTextField.backgroundColor = UIColor.whiteColor()
playerNameTextField.text = "some string"
playerNameTextField.borderStyle = UITextBorderStyle.RoundedRect
self.view?.addSubview(playerNameTextField)

but for some reasons it is not appearing over my game scene :(

Any clues?

Community
  • 1
  • 1
Devarshi
  • 16,440
  • 13
  • 72
  • 125
  • What happens? Any errors? – Austen Chongpison Sep 25 '14 at 03:36
  • Note: there is no Xcode6.1-beta2 (not yet anyway) – CodeSmile Sep 25 '14 at 09:44
  • @LearnCocos2D I downloaded couple of back from my developer account.. and 'yes' the dmg says - 'xcode_6.1_beta_2.dmg' – Devarshi Sep 27 '14 at 02:40
  • @WorkingDev.. no it is not showing any error.. I am just displaying some particles from emitter node, and trying to add text field to the same scene :( – Devarshi Sep 27 '14 at 02:46
  • @WorkingDev is there any way to show keyboard on SKScene without showing a text field, an example: I will show the keyboard as default on scene, and will render some nodes, if user taps 'A' I want to perform some kind of action on first node, if taps 'B' I want to perform some different kind of action on other nodes. Any suggestions? – Devarshi Sep 27 '14 at 02:54
  • @LearnCocos2D shall be glad if you propose any solution for my previous comment (which I asked from workingDev) :) – Devarshi Sep 27 '14 at 02:55

0 Answers0