質問

I want to know how to fire a method when a particular text box is edited.

For example, it is explained here how to assign a certain format to a textbox, using a number of functions. However, I don't know where to copy-paste these functions. In the explanation it says to use UITextFieldDelegate, but I don't know where it is.

I have a AppDelegate class, a ViewController class (including its xib), and a UITextField in the xib. I want the code to work for this UITextField.

役に立ちましたか?

解決

Add those methods in your ViewController.m class and then in your viewDidLoad method of ViewController.m Class

[yourTextField addTarget:yourTextFieldDelegate 
                             action:@selector(reformatAsCardNumber:)
                   forControlEvents:UIControlEventEditingChanged];

set reformatCardNumber: to be called whenever the text field fires a UIControlEventEditingChanged event

also add delegete in Viewcontroller.h file and Thats Done.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top