iphone - how to change the UIBarButtonItem size when rotate from the portrait to landscape? -


i add 1 uisegmentedcontrol navigation bar. when view loaded in portrait, frame seems right. when rotate landscape, uibarbuttonitem becomes larger. if rotate portrait again, still remain larger one.

some code snippet here:

#define segment_width   100.0 #define segment_height  32.0  cgrect segmentedcontrolrect = cgrectmake(0, 0, segment_width, segment_height); segmentedcontrol = [[uisegmentedcontrol alloc] initwithframe:segmentedcontrolrect]; segmentedcontrol.momentary = no; segmentedcontrol.segmentedcontrolstyle = uisegmentedcontrolstylebordered; [segmentedcontrol addtarget:self action:@selector(tabbuttonpressed:) forcontrolevents:uicontroleventvaluechanged]; uibarbuttonitem *segmentbarbtn = [[uibarbuttonitem alloc] initwithcustomview:segmentedcontrol];  self.navigationitem.rightbarbuttonitem = segmentbarbtn; 

some screenshots follows:

  1. loaded portrait mode. enter image description here

  2. rotate landscape mode. enter image description here

  3. rotate portrait mode. enter image description here

any suggestions appreciated.

do not use bordered style in navigation bar! use uisegmentedcontrolstylebar. that's it's for.

also, not set size (frame) of segmented control. create alloc-init , allow use own intrinsic sizing rules (sizetofit).


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -