我正在通过按钮操作在数组中一个一个地添加一个数组中的文本字段,同样我想从最后一个一个一个地删除另一个按钮中的这些文本字段,我应该怎么做我正在使用此代码添加
- (IBAction)btnAddTxtField:(id)sender {
// [self buttonPressed];
// currentIndex =0;
//
// int x = 132;
// int y = 550;
//
//
// UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake((currentIndex % 1) * x + 45, (currentIndex / 1) * y + 28, 214, 25)];
//
//
textField = [[UITextField alloc] initWithFrame:CGRectMake(76, ([txtFieldArray count] * 30), 191, 25)];
[textField setBorderStyle:UITextBorderStyleLine];
textField.font = [UIFont systemFontOfSize:20];
textField.placeholder = @"Enter text";
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.keyboardType = UIKeyboardTypeDefault;
textField.returnKeyType = UIReturnKeyDone;
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
textField.delegate = self;
[myScrollview addSubview:textField];
[txtFieldArray addObject:textField];
CGRect frame = bottomView.frame;
frame.origin.y += textField.frame.size.height + 5;
bottomView.frame = frame;
textField.hidden = NO;
}
并用于删除
- (IBAction)btnRemovTxtField:(id)sender {
[txtFieldArray removeLastObject];
textField.hidden = YES;
CGRect frame = bottomView.frame;
frame.origin.y -= textField.frame.size.height - 5;
bottomView.frame = frame;
}
我只想一个一个地删除文本字段,请帮忙