我正在通过按钮操作在数组中逐个添加textfields,同样我想从另一个按钮中删除这些文本字段,我应该怎么做我正在使用此代码添加从nsmutable阵列中删除对象
- (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;
}
我只是想删除文本框一个接一个,任何帮助,请
因此,您正在通过'removeLastObject'删除,那么问题是什么呢? – 2013-04-11 06:43:27
它不是删除 – NullData 2013-04-11 06:43:44
我想删除最后一个对象,如果按下按钮,然后再次按下按钮,直到数组计数为零或用户停止按下按钮 – NullData 2013-04-11 06:44:46