iphone - trying to add UILabel to some UIView organized by 2 columns -
iphone - trying to add UILabel to some UIView organized by 2 columns -
i'm adding n uilable n uiview organized 2 columns first uilabel shows up.
here code:
for(int i=0; i<ienen; i++){ uiview *ienasx = [[uiview alloc] init]; uiview *ienadx = [[uiview alloc] init]; ienasx.frame = cgrectmake(0.0, i*95.0, 160.0, 95.0); if(i%2==0) ienasx.backgroundcolor = [uicolor redcolor]; else ienasx.backgroundcolor = [uicolor greencolor]; uilabel *ienasxlabel = [[uilabel alloc] init]; ienasxlabel.frame = cgrectmake(0.0, (i*95.0)+80.0, 160.0, 15.0); ienasxlabel.text = [nsstring stringwithformat:@"iena n°: %i", i]; [ienasx addsubview:ienasxlabel]; [scrollview addsubview:ienasx]; ienadx.frame = cgrectmake(160.0, i*95.0, 160.0, 95.0); if(i%2==0) ienadx.backgroundcolor = [uicolor greencolor]; else ienadx.backgroundcolor = [uicolor redcolor]; uilabel *ienadxlabel = [[uilabel alloc] init]; ienadxlabel.frame = cgrectmake(160.0, (i*95.0)+80.0, 160.0, 15.0); ienadxlabel.text = [nsstring stringwithformat:@"iena n°: %i", i+1]; [ienadx addsubview:ienadxlabel]; [scrollview addsubview:ienadx]; }
see image clearer explanation: http://imageshack.us/photo/my-images/269/schermata20110716a18064.png/
is there can tell me i'm wrong?
thank much!
try setting label's frame:
ienasxlabel.frame = cgrectmake(0.0, 80.0, 160.0, 15.0);
the same for
ienadxlabel.frame = cgrectmake(0.0, 80.0, 160.0, 15.0);
also don't forget release objects (views , labels) after add together them superview.
iphone uiview uilabel
Comments
Post a Comment