开发者

uitextfield problem - retrieving

I have a 3 text fields and a button. I want to press on the first uitextfield, press on the button and hello world to be pasted, and same goes to the others. I know how to do this, but my method is too basic and I need to keep the same pasting code .. (so I guess in a way what im asking is, how can I retrieve the uitextfield that the user presses so I can alter it)

this is what i do:

if ( textfield1.isEditing ) {
   textfield1.text = ...
}

Is there a way I can get rid of 开发者_JAVA百科the variable textfield1, because if I have 1000 textfields I will have to write 1000 lines .. I can do loops but I want to retrieve the value somehow maybe using the sender? (new to xcode).


I think if you implement the textFieldDidBeginEditing function:

-(void)textFieldDidBeginEditing:(UITextField *)textField {
 // process text
}

and set the delegate of your text fields to the viewcontroller that contains this function. The input parameter textField should be the textfield that you are currently editing. This way you wont have to do the 1000 lines of code you mentioned.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜