universal xcode 3.2.6 Landscape mode by default - objective-c

How can i create universal apps using xcode 3.2.6 in Landscape mode bydefault?I need seprate .xib files for each view,Is i have to use this code
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscape);
}

In your plist, you should change supported interface orientations to just two items :
Item 0 Landscape (right home button)
Item 1 Landscape (left home button)
And use in each view controller:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (UIInterfaceOrientationIsLandscape(interfaceOrientation));
}

I use this sample code and for making its View based i just hide its Navigation bar by using this code
self.navigationController.navigationBarHidden = YES;
in the RootViewController_Phone.h and in RootViewController_Pad
BenellingsonPost

Related

ipad rotation in iphone project

I've created a project that is targeted just for iPhone (for now) and I chose supported orientation only Portrait. On iPhone it works great, but when I launch my project on iPad my application is rotating! Actually I tried to make it a universal app and in iPad deployment info I chose supported orientation only Portrait, my app still rotated on iPad. How may I fix that?
To only support Portrait mode in your view, implement the following in each of your views:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Also, you need to make sure that have set the Supported Device Orientations for each device as well:
You can manually set the rotation values in the view controllers by implementing this function:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait;
}

Force iOS app to launch in landscape mode

I am developing an app for iOS 5, which have to run in landscape mode. My problem is that I cannot get it to flip initially.
I have tried the adding "Initial interface orientation" set to "Landscape (right home button)"
and adding the following method to my view controller:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
I can wrap my head around how it is supposed to work. (I found the code here)
I am also wondering how to use the "Supported Device Orientation" available in the Xcode 4.2 project setup, it does not seem to do anything.
I have been looking around the website and have not been able to find an example that solves my problem.
Thank you.
In your application’s Info.plist file, add the UIInterfaceOrientation
key and set its value to the
landscape mode. For landscape
orientations, you can set the value
of this key to
UIInterfaceOrientationLandscapeLeft
or
UIInterfaceOrientationLandscapeRight.
Lay out your views in landscape mode and make sure that their autoresizing options are set correctly.
Override your view controller’s shouldAutorotateToInterfaceOrientation: method and return YES only for the
desired landscape orientation and NO
for portrait orientations.
use the following in appDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
also set the required orientations in
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
//Here are some iOS6 apis, used to handle orientations.
- (BOOL)shouldAutorotate NS_AVAILABLE_IOS(6_0)
- (NSUInteger)supportedInterfaceOrientations - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
When you click on your project's name in XCode and select your target under TARGETS, under Summary tab there's a visual representation of the supported device orientation settings. That was how I managed to do it.
i think if you at the supported interface orientations in the project plist it will work. just add a new line called "Supported interface orientations" and make it of array type and add 2 items for each of teh landsape views u want. havent tested this just a quick guess
Try this this will help you, write this code in you viewdidload.
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];

iphone Developing

I have 4 tabs in my application. After launching my application i want to start with landscape. Now i want to restrict one view from landscape, I tried with [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait]; now the view is restricting landscape and force the view into portrait then no issue right,now i will go to any other tab which are in my application they should not rotate to landscape mode.
After come back to home view where i was started my application then all are working fine.....
You need to add the following method to your UIViewController:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
If you want to allow Landscape:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
If you want to allow Portrait:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return UIInterfaceOrientationIsPortrait(toInterfaceOrientation);
}
If Both:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return YES;
}

iOS app - changing the orientation in tabbar

In my app I have a tabbar with 5 buttons. The total app has only portrait orientation and I have set it correctly.
My problem is that when I click the second button of the tabbar, the view appears normally in portrait but when the user tilts the device I want that particular view to be get changed to landscape. Is it possible to change the tabbar position to landscape and when the other buttons are clicked all to be changed to portrait?
Else while it is tilted I have to show the view alone in landscape without the tabbar, how can I do this?
So, to be clear, you want the entire app and all views in portrait EXCEPT for the view triggered by the second tab bar button, which you want to always appear in Landscape?
if I've not confused your question, than just put the following line of code in the "viewDidLoad" method of the controller of view number 2
self.view.transform = CGAffineTransformMakeRotation(M_PI / 2);
You probably want to bite the bullet and let your project accept multiple orientations at its highest level and then decide per UIViewController which orientations are supported. This will allow the frameworks to take care of a lot of the work for you (always a good idea).
In each view's controller, override this method:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
You will want to return YES for any orientation that you want the view to support.
The four options for the interfaceOrientation parameter are:
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
So for your case, you will want the view controller hosting your view and tab bar to support all of the orientations. This is how the function would look:
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return YES;
}
But for a extra detail, if you wanted to support only Landscape Left and Portrait Upside Down orientation, the function would look like this:
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}
A UITabBar only supports rotation, if the ViewControllers of all tabs return YES at shouldAutorotateToInterfaceOrientation.
You could achieve what you want, if you let your "portrait" tabs check if they are visible (via
tabbar.selectedViewController
or
tabbar.selectedIndex
and only reply yes when they're not selected.
The user experience could be confusing though, when the user changes the tab in landscape mode
a portrait view is presented ...
try this w.r.t.: tabbar.selectedViewController
[[UIDevice currentDevice] setOrientation:UIDeviceOrientationLandscapeRight];

Windows based iPad application orientation

I want to create iPad windows based application which support orientation by default windows application is not supporting orientation how to enable orientation support in windows based application in iPad.
Thank you
The window has no rotation functionality. It is allays in portrait mode. If you want something to rotate with the device, you should use UIViewController. It has to implement the method shouldAutorotateToInterfaceOrientation and return true for your orientations or remove it for all orientations.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
You should also change it in the project settings (ProjectName-Info.plist).