开发者

Editing multiple dynamically generated UITextFields at runtime

开发者 https://www.devze.com 2023-03-20 17:56 出处:网络
I have made an application in which user may generate as many UITextField as he/she wants and those will be automatically placed over a UIView. Functionali开发者_StackOverflow中文版ty is that user may

I have made an application in which user may generate as many UITextField as he/she wants and those will be automatically placed over a UIView. Functionali开发者_StackOverflow中文版ty is that user may drag the any of the UITextField at any point of screen.Till this part every thing is quite working. Now if he wants to edit the UITextField he taps(2 times) on UITextField and edits.This part of mine is only working for the recent generated UITextField not for all. How can i do this? I fnay one wants my previous code i can post. Plese respond it sonn. Thanks in advance.


        add textFieldArray to .h file then specify <UITextFieldDelegate> and

        sythesize that array.


        while creating the each textfield

        specify delegate like this

        mytextF1.delegate=self;

        mytextF2.delegate=self;

        .....


        after that add all text field object to an textFieldArray which should be declared .h file and synthesize them .(dont forget to alloc and init this array in ur viewdidload).


        self.textFieldArray=[[NSMutableArray alloc]init];


        then add each text field to this array

        [self.textFieldArray addObject:mytextF1];

        [self.textFieldArray addObject:mytextF2];

        .......

        then use this delegate methode to update

        - (void)textFieldDidBeginEditing:(UITextField *)textField{



            for (UITextField *textF in self.textFieldArray) {

                [textF setText:[textField text]];

            }



        }
0

精彩评论

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