0

I am generating UITextfields dynamically on a scrollview as the user enters number in the UITextfield (lets say it "A") and hits a button. But what i need to do is when user reenters number in UITextfields the previously displayed UITextfields must be gone and new UITextfields` must be generated.

for (UIView *field in self.scrollView.subviews)
{
     if([field isKindOfClass:[UITextField class]])
     [field removeFromSuperview];
}

eg- if first i generated 7 UITextfields and afterwards i edit the "A" again and put 3 as value only 3 UITextfields must be visible. but in my code the 3 UITextfields are overwritten on 7 but previous also displayed.

4

3 回答 3

0

But y did u regenrate new textfield if u can replace text in it and if u want animation then u can hide and unhide same textfield..

于 2013-04-19T10:02:25.423 回答
0

Set the following code in your reloadTxtinput method. Call this method when user taps the button.

-(void)reloadTxtinput {

   for(UIView *subview in [scrollview subviews]) {
      if([subview isKindOfClass:[UIButton class]]) {
        [subview removeFromSuperview];
      } else {
             //Do nothing
      }
  }

}
于 2013-04-19T10:09:44.727 回答
0

I have tried this code and this worked for me

for (y=1;y<=Pointsvalue;y++)
{
    UITextField *txtField =(UITextField *)[self.view viewWithTag:y+Pointsvalue];
    if (txtField.tag == y+Pointsvalue)
    {
        [txtField removeFromSuperview];
        [Feilds2Array removeAllObjects];
    }
}
于 2013-04-19T13:15:02.947 回答