0

ボタンアクションごとに配列にテキストフィールドを1つずつ追加しています。同じように、別のボタンのこれらのテキストフィールドを最後から1つずつ削除したいのですが、どうすれば追加するためにこのコードを使用していますか

- (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;

}

テキストフィールドを1つずつ削除したいだけです。助けてください

4

2 に答える 2