Dynamically insert more UITextFields

前端 未结 5 1590
没有蜡笔的小新
没有蜡笔的小新 2020-12-18 17:34

I have a requirement as described in the attached screen shot. When blue add button is clicked, one more UItextfield have to be inserted between last text field

5条回答
  •  天命终不由人
    2020-12-18 18:06

    On add button add a textfeild in subview and give the textfeild a unique tag so it will help you to differentiate between all textfeilds. For setting frame take the reference of your last textfeild frame and accordingly set the y coordinate.

    UITextField *textField = [[UITextField alloc] initWithFrame:yourFrame];
    textField.delegate = self;
    textField.tag=yourtag;
    [scrollview addSubview:textField];
    [textField release];//if arc is disable
    

提交回复
热议问题