mkmapview in landscape mode - iphone

Is it possble to show a map in landscape mode?

Yes.
The easiest way to accomplish it is to put your map view in a view controller that you then present in some way. Whatever orientations the view controller then supports will cause the hosted map view to rotate to automatically.
In your view controller you'd implement this method:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
That example handles both lanscape orientations. As long as your map view is set to autoresize correctly in your NIB file it should all just work.

Related

View is not rotating

I am making a navigation based app and I need only portrait orientation except in a ZoomPictureViewController ( Zoom in, zoom out images) that supports all orientations.
I am presenting ZoomPictureViewController and returning YES in shouldAutorotateToInterfaceOrientation:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
But I get no rotation. I know that shouldAutorotateToInterfaceOrientation, willRotateToInterfaceOrientation, RotateToInterfaceOrientation are only get called on the current/visible view controller but this is not happening in my case. I have checked it via putting breakpoints and NSLog.
Are you using any type of Navigation Controller or a Tab View Controller? I've noticed that there are issues when rotating a UIView that's not the first or only view as a direct child of the main window.
So if your UIView is part of a Navigation Controller or a Tab View Controller, you'll also need to override shouldAutoRotateToInterfaceOrientation on the Navigation Controller or Tab View Controller.
Also I here's an important gotcha in the Apple documentation that might explain the problem you are having.
Tab bar controllers support a portrait
orientation by default and do not
rotate to a landscape orientation
unless all of the root view
controllers support such an
orientation. When a device orientation
change occurs, the tab bar controller
queries its array of view controllers.
If any one of them does not support
the orientation, the tab bar
controller does not change its
orientation.

Programmatically Rotate UINavigationController

I know how to control the autorotation of a UINavigationController, but I would like to programmatically rotate a UINavigationController: the navigation bar, and view stack, to a specified UIInterfaceOrientation value, regardless of the current device orientation.
Is that possible?
Thanks
First, setup your application/view controller to use only one specific orientation (that is, block automatic rotations).
Then you can rotate the underlaying view layer (UIView.layer of type CALayer) using an affine transform.
Implement the - shouldAutorotateToInterfaceOrientation: in your view controllers insided the UINavigationController, only return YES on your desired orientation. e.g., the UINavigationController only display on landscape:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
May this helps.

Rotate view iPhone tabbar app

I have an app with a mainwindow which contains a tabbar controller and a number of different views. I want the whole thing to be able to rotate in each direction, however doing
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
didn't help, while that did work in other apps.
The UITabBarController requires that you enable rotation on all view controllers it manages. So each view controller should return YES for that method for the orientations you wish to rotate to.
If you wanted each view to rotate, you have to return YES on each view in the tab bar controller as well.

iPad & iPhone orientation: when I click my second view and rotate and then switch back to the first view my controls are not repositioned

I have an app for the iPad/iPhone and Portrait and Landscape is working just fine. However, I recently added a TabViewController and a second tab with a view. Problem is when I click my second view and rotate and then switch back to the first view my controls are not repositioned
Can anyone tell me what I need to do so that I can reposition my views when the first view is clicked?
incidentally, I am assuming I will have the same problem the other way too... view 2 to view 1.
Did you checked that all your view controller implement this method ?
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
From my experience, the same problem also occurs with navigation controller. I guess that the framework wont send the rotation event to every hidden VC on purpose to save processing time. The solution I ever did is just overriding viewWillAppear and correctly layout subviews there if needed.

Orientation of viewController

i am having tabBarController.It is having 3 viewControllers.I want to support landscape mode in only one of these viewControlers.and other 2 view controllers in potrait mode.How to achive this.
In the view controller you want to support landscape simply return YES to
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
Of course I'm assuming your implementation is creating a view controller for each view
Ya i am having view for each viewController.But i want to support landscape in only one view and rest all in potrait mode.Even i am returning YES in (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
if interfaceOrientation is landsape in view which i want to support and in rext views i am returning NO in this method if interfaceOrientation is landScape mode.