rotation - iPhone navigation bar height remains short in portrait orientation -


my app's root view controller supports orientation user can navigate view controller supports landscape orientation.

the basic problem regardless of device's actual physical orientation, when user pops root view controller, navigation bar has height appropriate landscape mode. figure out how navigation bar appear height of 44 (portrait height) instead of 32 (landscape height).

although navigation bar not set proper height, root view controller's uitableview offset correctly (44 pixels top of screen).

inside second view controller's -viewwillappear: perform standard rotational transform:

if (deviceorientation == uideviceorientationportrait)    {    uiscreen *screen = [uiscreen mainscreen];    cgfloat screenwidth = screen.bounds.size.width;    cgfloat screenheight = screen.bounds.size.height;    uiview *navview = [[self navigationcontroller] view];    navview.bounds = cgrectmake(0, 0, screenheight, screenwidth);    navview.transform = cgaffinetransformidentity;    navview.transform = cgaffinetransformmakerotation(degreestoradians(90));    navview.center = cgpointmake(screenwidth/2.0, screenheight/2.0);    [[uiapplication sharedapplication] setstatusbarorientation:uiinterfaceorientationlandscaperight];    } 

because secondary view controller allows navigation subordinate view controllers (as popping root view controller), have added following -viewwilldisappear:

if (deviceorientation == uideviceorientationportrait)    {    uiscreen *screen = [uiscreen mainscreen];    cgfloat screenwidth = screen.bounds.size.width;    cgfloat screenheight = screen.bounds.size.height;    uiview *navview = [[self navigationcontroller] view];    navview.bounds = cgrectmake(0, 0, screenwidth, screenheight);    navview.transform = cgaffinetransformidentity;    navview.center = cgpointmake(screenwidth/2.0, screenheight/2.0);    [[uiapplication sharedapplication] setstatusbarorientation:uiinterfaceorientationportrait];    } 

thanks advice on how force recalculation of navigation bar height.

not sure if there's better way, worked:

[[self navigationcontroller] setnavigationbarhidden:yes animated:no]; [[self navigationcontroller] popviewcontrolleranimated:yes]; [[self navigationcontroller] setnavigationbarhidden:no animated:no]; 

basically, hide nav bar, pop view controller , show nav bar. code somewhere adjusts nav bar height , everything's fine.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -