Ich habe einige Textfelder vertikal durch Storyboard hinzugefügt. Unter ihnen möchte ich mehr Textfelder programmatisch hinzufügen, aber es fügt immer nur ein Textfeld hinzu. Kann Textfelder vertikal in iOS nicht hinzugefügt werden?
Unten ist der Code
verwendetint i;
self.main_view.translatesAutoresizingMaskIntoConstraints = NO;
self.scroll_view.translatesAutoresizingMaskIntoConstraints = NO;
for (i=0; i<[arr_customEdtTxt count]; i++)
{
JVFloatLabeledTextField *tf = [[JVFloatLabeledTextField alloc] initWithFrame:CGRectMake(25, y, 270, 27)];
tf.textColor = [UIColor blackColor];
tf.font = [UIFont fontWithName:@"Helvetica" size:14];
CustomEditText *custom=[arr_customEdtTxt objectAtIndex:i];
tf.placeholder=custom.field_name;
tf.textAlignment=NSTextAlignmentLeft;
previousTextfield=tf;
//add bottom border
[self addBorder:tf];
tf.translatesAutoresizingMaskIntoConstraints = NO;
[self.main_view addSubview:tf];
y=y+27;
[self.main_view addConstraint:[NSLayoutConstraint constraintWithItem:tf attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.main_view attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0] ];
[self.main_view addConstraint:[ NSLayoutConstraint constraintWithItem:tf
attribute:NSLayoutAttributeHeight
relatedBy:NSLayoutRelationEqual
toItem:nil
attribute:NSLayoutAttributeHeight
multiplier:1.0
constant:27.0]];
[self.main_view addConstraint:[ NSLayoutConstraint constraintWithItem:tf
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:self.txt_email
attribute:NSLayoutAttributeWidth
multiplier:1.0
constant:0]];
if(i==0)
{
[self.main_view addConstraint:[NSLayoutConstraint constraintWithItem:tf attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.txt_exprience attribute:NSLayoutAttributeBottom multiplier:1 constant:15.0f]];
}
else
{
[self.main_view addConstraint:[NSLayoutConstraint constraintWithItem:tf attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:previousTextfield attribute:NSLayoutAttributeBottom multiplier:1 constant:15.0f]];
}
[arr_tf addObject:tf];
}
[self.main_view layoutIfNeeded];
[self setDatatoFields];
ich Einschränkungsfehler bekomme ich mehr Textfelder unter dem aktuellen Text fields.Please sagen hinzufügen möchten, wie kann ich mehr und mehr Text fileds unter
hinzufügen