Reputation: 17
I'm having some trouble dynamically removing UITextFields from my scrollview. I can add 2 UITextFields Dynamically. To remove UITextFields i am using the bellow given code
[dynamicUITextFields removeFromSuperview];
but only one UITextFields is removed and one Remains as it is .
I want both UITextFields to be removed
thanks in Advance
Upvotes: 1
Views: 271
Reputation: 569
I totally agree your solution. But it will remove all the UITextField from the current view
Step 1 Add the new added UITextField to Array
Step 2 Loop the array and remove the UITextField from SuperView
for(UITextField *textField in containerArray){
[textField removeFromSuperview];
}
Upvotes: 0
Reputation: 12719
If you want to remove all the UITextField
from a View, the use the following code.
UIView *container=self.scrollView;
for(UITextField *textField in container.subviews){
if([textField isKindOfClass:[UITextField class]]){
[textField removeFromSuperview];
}
}
Cheers.
Upvotes: 1