2016-03-19 16 views
-2

Hikaye panosu aracılığıyla bazı metin alanlarını dikey olarak ekledim.Belirtikçe programlı olarak daha fazla metin alanı eklemek istiyorum ancak her zaman sadece bir metin alanı ekliyor. Aşağıda enter image description hereiOS'ta metin alanları dikey olarak eklenemiyor mu?

kod i

aşağıda daha fazla metin fileds ekleyebilir nasıl anlatmak fields.Please geçerli metnin altında fazla metin alanı eklemek istediğiniz ı sınırlama hatası alıyorum

int 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]; 

kullanılır

cevap

0

O previousTextfield ve tf benziyor bu satırda aynı textfield bakın:

[self.main_view addConstraint:[NSLayoutConstraint constraintWithItem:tf attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:previousTextfield attribute:NSLayoutAttributeBottom multiplier:1 constant:15.0f]]; 
if(i > 0){ 
    //Change arr_tf for arr_customEdtTxt if that is your array 
    previousTextfield = [arr_tf objectAtIndex:i-1]; 
} 
:Ayrıca ben sizinle previousTextfield = tf değiştirmelisiniz textfields sizin dizisi olan sonunda sen arr_tf textfield'ı eklemek ama aynı zamanda hangisinin bağlı arr_customEdtTxt olduğunu fark ettik
İlgili konular