How to set content size to fit UINavigation panel
I resize the navigation bar when my app switches to landscape orientation. But I can't seem to set the size of the content of the navigation bar to match its height.
Landscape Image : - In this image, the top-left item and the title of the navigation bar do not change when it switches to landscape orientation .... they should be sized to fit the height of the navigation bar.
Please suggest me any idea for this?
Thanks
Deepika
a source to share
override method:
- (UIView *)rotatingHeaderView
{
return yourNavigationBar;
}
this method is called when orientation of your device occurs.
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(mainLoginView.superview == self.view || modulesView.superview == self.view)
{
return NO;
}
else
{
return YES;
}
}
replace this method with your code and tell me what happens :)
a source to share
I am using this delegate method: -
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
if(mainLoginView.superview == self.view || modulesView.superview == self.view){
return NO;
}else{
[self rotateTheNavigation:contactsNavigation withOrientation:interfaceOrientation];
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
}
a source to share
If you need to recalculate your views, it is better to put your code in
-
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
, - or
-(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
shouldAutorotateToInterfaceOrientation should only answer the question: "Should this controller rotate or not?".
For instance:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
// Get the new screen width
self.cellWidth = self.view.frame.size.width;
// Recalculate the view
[self rebuildTheView];
}
In most cases, implementing shouldAutorotate in all of your ViewControllers is sufficient as long as you set the correct resizing options in the Interface Builder. Make sure you do this before implementing didRotateFromInterfaceOrientation or willAnimateRotationToInterfaceOrientation
For instance:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return [ViewToolkit orientationIsSupported:interfaceOrientation];
}
a source to share