Views are portrait in older versions - iphone

I have a problem here and am not able to come up with answer why my app is behaving so.
I made application using XCode 4.5+ and iOS6 and have set my application to work in landscape mode it was working and running fine till I tried to run it in previous version like iOS 5.1 simulator or below all views are in portrait mode :(

You can try defining this method in your controllers:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return ( interfaceOrientation == UIInterfaceOrientationPortrait)ç
}
This plays the same role as shouldAutorotate for iOS6.

as suggested by tkanzakic - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOr‌​ientation solved my problem with lower versions thanks a lot :)

Related

set cocos2-x project to portrait orientation

I am trying to set up my project with portrait orientation, but I am just getting landscape. I am using cocos2d-x (2.1.4).
I have set, as said here:
At RootViewController.mm:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsPortrait( interfaceOrientation );
}
// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
- (NSUInteger) supportedInterfaceOrientations{
#ifdef __IPHONE_6_0
return UIInterfaceOrientationMaskPortrait;
#endif
}
I also tried changing the settings, still nothig.
setDeviceOrientation does not exist anymore...
Anyone knows how I can set the project to portrait??
UPDATE: It seems to work on the device, it only happens on the simulator
I do it this way: In xcode at the top of the file list is the project. Go to that, then the "Targets > whatever" bit. You have "supported Interface orientations". You can check off which orientations you want and don't want. Make sure to note that there are 2 different sections for iPhone and iPad, you'll have to scroll down and set it separately in the iPad orientation section.
I'd imagine the reason it doesn't work in the simulator is that you're using an iPhone/iPod for testing and running the iPad simulator.

Supporting iOS 4.3 to iOS 6.0

I already have the base code that supports ios 4.3 to ios 5. Now I would also like to support ios 6.0.
The present base code has modal views, hard coded CGRect's, and rotation is different for each view. So I would like to know whether we can support ios 4.3 to ios 6.0 with the same base code, by just tweaking some changes, or do we need to create a complete new target?
Like we cannot use auto layout of ios 6.0 if I want to support previous versions as it will lead to a crash.
Yes, we can do this by setting up the Deployment Target to iOS 4.3. But then, why do you need to support iOS < 5.0 as around 85-90% of devices are on iOS 5.0+. See this
Also, when you set up support for iOS 4.3 or even iOS 5.1.1, you would have to handle multiple things. For example, the method for Orientation,
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
isn't called for iOS 6. It is replaced by the methods,
- (NSUInteger)supportedInterfaceOrientations
- (BOOL)shouldAutorotate
You would need all the iOS versions on devices and then test each and every aspect of your app.
Using Xcode 4.5 it is perfectly valid to use one code base for building iOS 4.3 - 6.0 apps, but as always the key is testing on real iDevices with the given operating system versions.
Yes it is perfectly fine and can be done to support ios 4.3 to ios 6.0 using the xcode 4.5.
And for the orientations in ios 6 have to do some work around like have to put some code differently as posted in #Mayur J's answer.
Or all you can do is just add categories for the required controller's like UINavigationController, UIPopoverViewController, UIImagePickerViewController, etc to return the supported orientation in ios 6.0 like below
.h file
#import <UIKit/UIKit.h>
#interface UIPopoverController (UIPopoverController_Orientation)
-(NSUInteger) supportedInterfaceOrientations;
#end
.m file
#import "UIPopoverController+UIPopoverController_Orientation.h"
#implementation UIPopoverController (UIPopoverController_Orientation)
-(NSUInteger) supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
#end
Here I use UIInterfaceOrientationMaskLandscape as I only supports landscape orientations ie restrict my app to only landscape mode.
Hope this will help you.
Happy Coding :)

Re-enable landscape orientation in Xcode 4

I temporarily disabled landscape orientations in my iPhone app while I fixed a problem with an image. Now, for the life of me, I can't get any pages to AutoRotate to either landscape orientation. It worked fine previously. I have all 4 orientations identified in the UISupportedInterfaceOrientations in the info.plist. All 4 orientations are highlighted in the Targets Summary Supported Device Orientations. My implementation files all have:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
I'm sure it's something stupid I'm missing, but I can't find it after trying for hours. Any thoughts????
If you are certain that each viewController has
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
then you may want to try deleting the Build/ directory, selecting clean all targets in the build options, and then relaunching the app. Sometimes this miraculously works. Also, closing and re-opening the simulator and/or Xcode is a common mystery solution for me.
If this doesn't work, then you may want to read through Apple's trouble shooting guide: Why won't my UIViewController rotate with the device?
You may want to clean all targets - the updated plist may not be getting copied into the app bundle. If this is on the device, you may try deleting the app from the device as well.

iPhone app autorotates on one device, but not another

Does anyone know of a reason why an iPhone would autorotate on one device, but not another? I can't reproduce it on my iPhone, iPod Touch, or any of the simulator devices.
Are there any device settings I should be paying attention to? The offending iPhone has the same SDK version installed (4.2.1), but is a different model (MC319LL) than mine (MC605DN).
Well, I never figured out why the two phones were acting differently, but this bit of code in in the UITabBarController subclass seems to have solved things:
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return toInterfaceOrientation == UIInterfaceOrientationPortrait;
}
You made sure that the misbehaving device had its rotation lock turned off in the settings, right?

UI autorotation works only on some devices?

I'm having quite interesting (but very annoying) problem with (not only) UI autorotation. I'm working on the app which contains tabbar controller with couple of navigation controllers as tab items. One of those controllers allows for autorotation to landscape mode.
Interesting is that it perfectly works in Simulator as well as on my own device, but it's not working on other testing devices. All devices are the same - iPhone 3G 16 GB, OS version 3.1.3.
When I'm looking for a log messages which report orientation change events in console, I can find it again only on my device, but not on other devices, so it seems that other devices do not report orientation change at all. Which is very unlikely on the other hand, because other apps are working normally... Also some other features which are working on my phone are not working on other devices too (touch events handling in tableview for instance).
I've never seen something like this and cannot find any reason why the hell it should not work on all devices the same way! So the question is - am I mad or what?
I use subclass of UITabBarViewController with overriden method
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) toInterfaceOrientation {
BOOL shouldRotate = (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft);
NSLog(#"Should rotate: %d", shouldRotate);
return shouldRotate;
}
Then I handle orientation change animation in respective methods (willRotate..., willAnimateRotation...). But as I said - it works fine on my device, but on other devices the shouldAutorotateToInterfaceOrientation: method gets never called. Weird!
Please give me some hint before I'll end in a madhouse. Thanks for any tip.