objective c - iphone sdk 4.2: UIBarButtonItem' s are misplaced over UIToolbar -


i have installed 4.2 iphone sdk today , ran project (which written in 4.0) 4.2. noticed toolbar items misplaced on toolbar, both in ipad, iphone simulators. there else other me has encountered this? here code:

@define toolbar_height 34 @define toolbar_item_width 90  // extends uiview @implementation mapviewcontrollercontainer - (void) setframe:(cgrect)frame {     [super setframe:frame];     if (self.subviews.count == 2)     {         ((uiview *)[self.subviews objectatindex:0]).frame = cgrectmake(0, 0, frame.size.width, toolbar_height);         ((uiview *)[self.subviews objectatindex:1]).frame = cgrectmake(0, toolbar_height, frame.size.width,                                                                         frame.size.height - toolbar_height);     } } @end  // extends uiviewcontroller @implementation mapviewcontroller - (void) loadview {     self.view = [[mapviewcontrollercontainer alloc] init];     [self.view release];      uitoolbar * toolbar = [[uitoolbar alloc] init];     toolbar.barstyle = uibarstyleblack;       uibarbuttonitem * flexibleitem = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace                                                                                     target:nil action:nil];     detailsbutton = [[uibarbuttonitem alloc] initwithtitle:nslocalizedstring(@"details",@"")                                                       style:uibarbuttonitemstylebordered target:self                                                      action:@selector(detailspressed)];     detailsbutton.width = toolbar_item_width;     detailsbutton.enabled = no;     toolbar.items = [nsarray arraywithobjects: flexibleitem, detailsbutton, nil];     [flexibleitem release];     [detailsbutton release];      [self.view addsubview:toolbar];     [toolbar release];      // more non-related code here } @end 

here output:

output http://dl.dropbox.com/u/13741164/toolbar.jpg

as see, details button out of frame right side. smaller toolbar_item_width, more inside frame. suppose there bug in calculation of toolbar items, because works wonderfully in 4.0 sdk, right? help.

the following call fixed issue me:

[toolbar sizetofit]; 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -