4

i make the next method in a viewController

-(void)setupDocsLabel:(NSMutableArray *)documents{      
    self.lDocumentos.frame = CGRectMake(self.lDocumentos.frame.origin.x, kFirstLabelYPosition+actualLabelYPos,self.lDocumentos.frame.size.width,lDocumentos.frame.size.height);
    self.Documentos.frame = CGRectMake(self.Documentos.frame.origin.x, kFirstLabelYPosition+actualLabelYPos,self.Documentos.frame.size.width,self.Documentos.frame.size.height);

    actualLabelYPos +=20.0;


    for (DocInformation *doc in documents) {
        NSString *textLabel = [doc.documentDescription stringByAppendingString:@" :"];
        UIFont *lblFont = lDocumentos.font;
        CGSize sizeFont = [textLabel sizeWithFont:lblFont forWidth:120.0 lineBreakMode:NSLineBreakByTruncatingTail];

        UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(lDocumentos.frame.origin.x+20, kFirstLabelYPosition+actualLabelYPos,sizeFont.width,sizeFont.height)] retain];
        label.text = textLabel;
        [label setFont:lblFont];
        [label setTextColor:lDocumentos.textColor];
        [label setBackgroundColor:[UIColor clearColor]];
        //[label setLineBreakMode:NSLineBreakByTruncatingTail];


        NSString *textDoc = doc.cdgoDocum;
        UIFont *lblFontDoc = Documentos.font;
        CGSize sizeFontDoc = [textDoc sizeWithFont:lblFontDoc];

        UILabel *labelDoc = [[[UILabel alloc] initWithFrame:CGRectMake(label.frame.origin.x+label.frame.size.width+20, kFirstLabelYPosition+actualLabelYPos,sizeFontDoc.width,lDocumentos.frame.size.height)] retain];
        labelDoc.text = textDoc;
        [labelDoc setFont:lblFontDoc];
        [labelDoc setTextColor:lDocumentos.textColor];
        [labelDoc setBackgroundColor:[UIColor clearColor]];

        [self.scrollView addSubview:label];
        [self.scrollView addSubview:labelDoc];

        [label release];
        [labelDoc release];

        actualLabelYPos+=20.0;
    }
    //[self.view setNeedsDisplay];
    //[self.view setNeedsLayout];
}

New Labels add to the scrollView well, but self.lDocumentos (a IBOutlet of the .xib) don´t change his position.

Thanks for the help!!

AndyDev
  • 1,409
  • 10
  • 17
sheltrinec
  • 121
  • 1
  • 5
  • When are you calling the `setupDocsLabel` method? remember that IBOutlets are assigned on `viewDidLoad`, which is lazy loaded when you access the `view` property – Angel G. Olloqui Sep 12 '12 at 12:31
  • The method is called in the viewDidLoad. When I inspect the property, this is instantiated. I do not know what else I can try. – sheltrinec Sep 12 '12 at 13:03

1 Answers1

8

I've solved it, the problem was that the .xib had enabled Use AutoLayout in the File Inspector.

Niklas Berglund
  • 3,563
  • 4
  • 32
  • 32
sheltrinec
  • 121
  • 1
  • 5