Reputation: 111
I'm making an easy app where I have textFields. When the app starts I have examples in my textfields. I want these text examples to be deleted when users tap on textField. Can anybody help me?
Upvotes: 4
Views: 2250
Reputation: 1818
You can set Placeholder text in UITextField. Whenever, UITextField is tapped placeholder text disappears.
Alternatively, you can use following UITextFieldDelegate method
Objective-C
- (void)textFieldDidBeginEditing:(UITextField *)textField {
textField.text = ""
}
Swift
func textFieldDidBeginEditing(textField: UITextField) {
textField.text = ""
}
Upvotes: 4
Reputation:
Just add this underneath your didMoveToView method in youre SpriteKit Game
override func touchesBegan(touches: Set<UITouch>, with Event event: UIEvent?) {
for touch in touches {
let location = touch.locationInNode(self)
if nodeAtPoint(location) = textField {
textField.removeFromParent()
}
}
}
Upvotes: 1
Reputation: 11
I think you are trying to create text field with placeholder.
this link might helps you.
Upvotes: 0