iphone - resize toolbar in UINavigationController -


i'm adding series of buttons uinavigationbar using:

    nsarray *items;          items = [nsarray arraywithobjects:                  fixedspace,                  refreshstopbarbuttonitem,                  flexiblespace,                  self.backbarbuttonitem,                  flexiblespace,                  self.forwardbarbuttonitem,                  flexiblespace,                  self.actionbarbuttonitem,                  fixedspace,                  nil];      uitoolbar *toolbar = [[uitoolbar alloc] initwithframe:cgrectmake(0.0f, 0.0f, toolbarwidth, 44.0f)];      toolbar.items = items;      toolbar.tintcolor = [[uicolor whitecolor] colorwithalphacomponent:1.0];      toolbar.autoresizingmask = uiviewautoresizingflexibleheight;      self.navigationitem.rightbarbuttonitem = [[uibarbuttonitem alloc] initwithcustomview:toolbar]; 

all working well.

however when rotate landscape mode toolbar within uinavigationbar doesn't rotate.

adding code (found on so) causes toolbar resize not buttons within it, partially cropped @ bottom , no longer lines toolbar background

- (void)willanimaterotationtointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation duration:(nstimeinterval)duration {     cgrect navigationtoolbarframe = self.navigationcontroller.navigationbar.frame;     cgrect customtoolbarframe = cgrectoffset(navigationtoolbarframe, 0.0, navigationtoolbarframe.size.height);     [uiview animatewithduration:duration animations:^{         //self.toolbar.frame = customtoolbarframe;         // fails!!!         //self.navigationitem.rightbarbuttonitem.toolbar.frame = customtoolbarframe;         // fails!!!     }]; } 

what correct way address toolbar within uinavigationbar? like...

self.toolbar.frame = customtoolbarframe; 

or have specify autoresizemask uibarbuttonitems?...

self.backbarbuttonitem.autoresizingmask = uiviewautoresizingflexibleheight; 

... trying fails

  1. very curious because code rotates toolbar fine when include in code. no problem rotating toolbar.

  2. i assume view controller responding shouldautorotatetointerfaceorientation? include screen snapshot of you're seeing?

  3. are doing uitoolbar category/subclass eliminate border? (i subclass empty (void)drawrect:(cgrect)rect rid of border, tried both , standard uitoolbar , both rotated fine.) anyway, if you're doing subclass/category of uitoolbar, please include code?

  4. also, alternatively use ios 5's rightbarbuttonitems , bypass toolbar altogether, e.g. self.navigationitem.rightbarbuttonitems = items; add array of uibarbuttonitem objects navigation bar.

  5. this bit of long shot, how view controller being loaded? people try bypassing presentviewcontrolleranimated and/or pushviewcontroller , instead create view controller, grab view, add subview of previous view controller's view. unfortunately, ends disconnect between view controller hierarchy , view hierarchy, , according wwdc 2011 session 102 on view controller containment, can prevent rotation events being transmitted correctly. make sure you're using presentviewcontrolleranimated or pushviewcontroller if isn't root view controller.

i don't of willanimaterotationtointerfaceorientation or subsequent code, simple uitoolbar , works fine during rotation, wonder if problem rests elsewhere.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -