iphone - label is not visible in UIToolBar -


i attempting set label subclassed uitoolbar. first creating label, converting uibarbuttonitem , setting them toolbar, toolbar appears blank.

here code in init method of subclassed toolbar

nsmutablearray *items = [[nsmutablearray alloc] init];  // prep total label _totallabel = [[uilabel alloc] init]; _totallabel.font = [_totallabel.font fontwithsize:15]; _totallabel.textcolor = [uicolor whitecolor]; _totallabel.text = nslocalizedstring(@"total", nil); _totallabel.frame = cgrectmake(0, 0, 100, 44); _totallabel.autoresizingmask = uiviewautoresizingflexiblewidth | uiviewautoresizingflexibleheight | uiviewautoresizingflexibletopmargin; _totallabel.layer.borderwidth = 2; _totallabel.layer.bordercolor = [uicolor greencolor].cgcolor; _totallabel.backgroundcolor = [uicolor clearcolor];  uibarbuttonitem *spacer2 = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:nil action:nil]; [items addobject:spacer2];  uibarbuttonitem *total = [[uibarbuttonitem alloc] initwithcustomview:_totallabel]; [items addobject:total];  [self setitems:items]; 

any idea whats wrong?

where calling code from? if have in initwithframe: or initwithcoder: not work.

try this:

- (void)layoutsubviews {      [super layoutsubviews];      if(self.items.count == 0) {         //your code here     } } 

that working. question though should doing in layoutsubviews? not. put setup method on uitoolbar , call @ later point in application.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -