iphone - UILabel out of app frame -
my lables out of app frame:
only when im scrolling can see rest:
[_scroller setscrollenabled:yes]; [_scroller setcontentsize:cgsizemake(320, 600)]; self.description = [_description stringbytrimmingcharactersinset:[nscharacterset whitespaceandnewlinecharacterset]]; [self positionlabel:self.lbltitle withtext:self.stitle withy:10]; [self positionlabel:self.lblpubdate withtext:self.pubdate withy:cgrectgetmaxy(self.lbltitle.frame)+10 ]; [self positionlabel:self.lbldescription withtext:self.description withy:cgrectgetmaxy(self.lblpubdate.frame)+10 ]; } -(void)positionlabel:(uilabel*)lbl withtext:(nsstring*)text withy:(cgfloat)y { lbl.textalignment = uitextalignmentright; lbl.text = text; lbl.numberoflines = 0; lbl.linebreakmode = nslinebreakbywordwrapping; cgsize size = [self calculatesize:lbl]; //fixed [lbl setframe:cgrectmake(10 , y , (size.width>300)?size.width:300 , size.height)]; [_scroller addsubview:lbl]; } -(cgsize)calculatesize:(uilabel*)lbl { cgsize size = [lbl.text sizewithfont:lbl.font constrainedtosize:cgsizemake(280, maxfloat) linebreakmode:uilinebreakmodewordwrap]; return size; }
what cauase problem? labels in xib may related?
you not setting y co-ordinate
of scrollview set proper scrollview frame.
after adding scrollview subview set frame.
cgrect frame = yourscollview.frame; frame.origin.y= frame.origin.y + 49; //49 navigationbar height. [yourscollview setframe:yourscollview.frame];
Comments
Post a Comment