I can't make iPad application autorotate window subviews. I have created two identical applications for iPhone and iPad that are similar to an Apple example app.
Everything seems simple: overriding shouldAutorotateToInterfaceOrientation method of UIViewController, returning YES, and that's all.
In iPhone everything works fine, but not in iPad. I see that rotate animation runs when I flick the device, but all subviews (UILabel and UIImageView) stay on.
What can be wrong?
Related
I´ve tried running my iOS (for iPhone) game built with cocos2d on an iPad and almost everything works just fine, except the first screen to display where the UI elements is all over the place.
However, if I switch to another View (or Scene in Cocos2d) everything looks great and if I switch back to the previously messed up screen, it also looks normal.
So, the first screen to load when running on the iPad will look messed up and I have no idea what´s causing this.
Any ideas?
This generally happens when you inherit your scene class from CCNode. Change the parent class of your scene to CCScene.
I have an iPad app which supports Portrait and Landscape in the entire app. This is an iOS 7 and iOS 8 version of an app.
The app is a UITableViewController with multiple segues to a different set of UIViewControllers. I have one option in the app to show the Tutorial again and I have created the images in a Portrait mode only orientation because it just wouldn't make too much sense (or look good in Landscape).
With this in mind, the tutorial is in the form of images loaded into a UIPageViewController. The images are loaded in the viewDidLoad and the buttons and layout work really well.
Issue
I want to restrict the UIPageViewController to be in a Portrait orientation only.
Currently, I have:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[[UIDevice currentDevice] setValue:
[NSNumber numberWithInteger: UIInterfaceOrientationPortrait]
forKey:#"orientation"];
}
That works to some extent. If the device is in Landscape mode and the tutorial is invoked, it rotates it to Portrait.
However, if the device is in Portrait and I rotate it to Landscape after invoking the Tutorial, the tutorial then rotates.
How exactly do I prevent this view from rotating in my custom UIPageViewController class, so that it never rotates to Landscape whether it's at the start, middle, or end of the tutorial.
Any guidance on this would really be appreciated.
Take a look at UIViewController docs for Orientation support, specifically shouldAutorotate: and supportedInterfaceOrientations- https://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UIViewController_Class/index.html#//apple_ref/occ/instm/UIViewController/supportedInterfaceOrientations
My first guess would be you would want to set the value like you're doing now, and then override shouldAutorotate in your custom UIPageViewController subclass and return NO.
However, be aware you could get hit in the review process for HIG compliance, because your app claims to support all orientations, but parts of it don't. Obviously this is totally up to the reviewer and whether or not they catch it as plenty of other apps do this.
I'm updating an existing app for iOS7. The app uses a UIToolbar with two UIBarButtonItem's, one on the left, the other on the right.
The left UIBarButtonItem works as expected. The right UIBarButtonItem does also, except in landscape orientation on iOS7. It works fine in iOS6 (all orientations), and in portrait mode (only) in iOS7. I'm seeing this in both the simulator and on my iPad mini.
The button is obviously correctly bound to a segue (since it usually works), and I have confirmed that it is enabled even when it is not working. (My view controller has an update timer, and I log the state on every tick.)
Has anybody else seen something like this? Any ideas?
TIA,
Doug K;
My app is entirely designed for IOS6. I use an xib for the iPhone and another one for the iPad. My AppDelegate sets up a TabBarController, though there is no class for the TabBarController itself. The TabBarController has two tab items, 1 a NavigationController, and 1 a View Controller, each of which has its own class. I would like the iPad to be able to run in just Portrait mode, upside down, and normal. On the summary tab of Target in Xcode, I have supported interface orientations set to Portrait and Portrait Upside Down.
My understanding with iOS 6 is that you only need to put
- (NSUInteger)supportedInterfaceOrientations
in the highest parent controller of a class, and set which Masks you would like it and all the child containers to work with. So, in the Root View Controller of the Navigation Controller I put:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskPortraitUpsideDown;
}
And in each of the child classes, I put:
- (BOOL)shouldAutorotate{
if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
{
return YES;
}
else
{
return NO;
}
}
I then put the same two methods in the 2nd Tab which was just a View Controller Class.
I installed the app on my iPad, and it worked fine in portrait mode, but did not rotate when I turned it upside down. I exited the app and turned the iPad upside down, but when I started the app again, it still stayed in the same spot. So, I killed the app completely, and started it from the beginning upside down. The splash screen was upside down, but when the screen disappeared, the app was still only showing in portrait mode, making the display upside down.
What am I missing?
click on appName select Target and just select the orientations which you want to support. thanks
The code above is great for pre iOS 6. For iOS 6 you have to use the mask orientation. If you want all of the views in iPad to rotate or just some you have the choice of using the above answer. If you want to hard code it the check my answer in the following link for a detailed code for autorotation of all masks or just rotate one view and let the others don't rotate. Any how here is the link
iOS 6 supportedInterfaceOrientations issue
The above answer is providing you with the right solution as well but if you want to learn how to code it check my answer in the link above. Happy coding.
Is the Rotation Lock enabled or not ? (If you are new to iOS, double tap the home button, and slide to the right: it's the little metal-styled button in shape of an arrow).
If you want to run your application to run on portrait mode only than,
1. Select Your Target.
2. In General -> Development Info -> Device Orientation Uncheck all other orientation.Portrait mode only should be checked.Than run your project.
I'm creating a cocos2d game on iOS that uses the accelerometer. I just started testing on an iphone 5 and for some reason, it's reversing the accelerometer data - basically it behaves as if the screen orientation is 180 degrees flipped from how it actually is, tilting down causes it to send things up, left goes right etc.
It works fine on my iphone 4 running iOS 5 and on both my ipad running iOS 5 and my ipad running iOS 6. Not sure if it's an issue with just the iphone 5 or all iphones running iOS 6.
I can't find any mention of this issue online, wondering if anyone else is running into this and if you know of a solution.
OK I figured out what was going on. In iOS 6 the willRotateToInterfaceOrientation method is deprecated and no longer gets called. I had code in there to do two things - detect which landscape orientation the phone was loading into and adjust the variables accordingly, and to prevent the phone from flipping the orientation during gameplay (it's a tilt-to-move game). The reason everything was behaving as if the view was upside-down was because it was, and the phone's orientation was locked, and my code to correct for that wasn't being called. Here's what Apple says about willRotateToInterfaceOrientation:
The willRotateToInterfaceOrientation:duration:,
willAnimateRotationToInterfaceOrientation:duration:, and
didRotateFromInterfaceOrientation: methods are no longer called on any
view controller that makes a full screen presentation over itself—for
example, by calling presentViewController:animated:completion:. You
should make sure that your apps are not using these methods to manage
the layout of any subviews. Instead, they should use the view
controller’s viewWillLayoutSubviews method and adjust the layout using
the view’s bounds rectangle.
Now I just need to figure out how to use the willLayoutSubviews method to replicate my original functionality.