我想通过从数组添加按钮单击添加五个文本字段,并通过删除按钮单击删除新添加的文本字段。当我点击添加按钮五个文本字段一次又一次添加时,当我点击添加按钮它正常工作。但是当我点击删除按钮时,只有当我点击删除按钮时,新添加的五个文本字段被删除不再被删除。 这是我的代码
enter code
- (void)CreateTextField //单击按钮时再次创建5个文本字段 { 的NSLog(@"%d",i)的;
i=i+1;
NSArray *array;
array=[[NSArray alloc]initWithObjects:@"Degree",@"Branch",@"Passing Year",@"Grade/%",@"Institute", nil]; /* these are Five text field name
textFieldArray = [[NSMutableArray alloc] init];
for (int k = 0 ; k< [array count]; k++)
{
}
-(void)DeleteTextField // delete last newly add added text field by delete button click but deleted only once not again and again deleted by click on it
{
NSLog(@"%lu",(unsigned long)[textFieldArray count]);
int var = [textFieldArray count] - 5;
int test = [textFieldArray count];
for(int p = test;p>var;p--)
{
NSLog(@"%d",i);
[[textFieldArray objectAtIndex:p-1] removeFromSuperview]; /* code to remove newly added text field by delete button click
[textFieldArray removeObjectAtIndex:p-1];
} here
答案 0 :(得分:0)
看到您只发布了代码,没有任何描述,我只能假设您需要BroadcastReceiver
中空for循环的代码。
试试这个:
CreateTextFields
当然,您需要设置自己的尺寸,而不是我的样本中指定的硬编码尺寸。当你正在寻找的东西时,这应该可行。祝你好运!!