iPad app not laying out properly - ios

I have an iPad app that I've inherited the code for.
I'm relatively new to iPad development, so please bear with me...
The app was compiled off-site by a contractor in 2010. Since then, my company has been acquired and we're in the process of rebranding. My seemingly simple task is to replace our logo in this app with a new logo. It should take a few minutes - just drop a new logo into the code, compile, and bam! Done.
There's a problem with compiling the code...the working app launches in landscape mode and fills the entire screen with its interface. When I compile the app in the simulator or run it on my iPad (connected to my mac via USB cable), the screen launches in landscape mode, but the view is in portrait mode. In intermittent places throughout the app, the views switch from landscape to portrait layout.
This is driving me nuts because I don't even know what to look for. I see some references to shouldAutoRotateToInterfaceOrientation - I think that's been deprecated. Could that be causing the problem?
I know a LOT has changed since 2010. I'm currently running the latest version of XCode on a new mac. (From what I understand, my predecessor never actually compiled the app here, but relied totally on the contractor...from what I can see, this may be a problem that's been there all along, but nobody was aware of)
UPDATE
I have an older mac (with an older version of XCode) to test with. I've moved the app code onto the older mac, changed a few settings, and it works correctly.
I've also noticed the layout isn't quite correct on ANY app I create on my new mac. For example, dropping a button near the top of the form winds up scrolled off the top of the app, so it's not even visible.
Is there a setting in XCode that defines this behavior?

In iOS 6.0 check for view controller orientations condition is changed..
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
return YES;
}
else
{
return NO;
}
}

Related

Screen Rotation in iOS

I need some help regarding "Screen Rotation". I am creating this application in Landscape mode but I also want to be able to turn the iPad to Portrait mode. I am trying something different and making the application inside the viewcontroller. Basically copy and paste a view controller over and over. My issue is that even after I select, "Portrait" to be the ViewControllers Mode it still changed to landscape when i the iPad is turned to Landscape mode. I hope this made sense. Any answers are greatly appreciated!
If you're setting the supported orientation modes under the 'Deployment Info' section of your project file in Xcode, might be worth double checking that you are setting the modes for iPad rather than iPhone if you setup your project as a Universal app.

iOS 3.2 to iOS 7 interface orientation inconsistency

I have a very old app that's compatible with iOS 3.2+ devices (both iPads and iPhones). And I have a big issue making it compatible with iOS 7!
In fact, it has been written long ago before ARC, storyboards and all that syntactic sugar we are pleased to play with nowadays. And I'm having a very hard time trying understanding some interface orientation issue:
For the iPhone, the app is only visible in landscape... No problemo with the main ViewController. But the settings one (a simple ViewController with a UITableView in it) is always displayed in Portrait !!! Whatever the properties I set and the methods I write.
In the .plist I have only supported orientations LandscapeLeft and Right. In the Settings View Controller, I have those methods:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation) || (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone);
}
- (BOOL) shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)?UIInterfaceOrientationMaskLandscape:UIInterfaceOrientationMaskAll;
}
But what really bothers me is that when I display self.interfaceOrientation it says Landscape (in the viewWillAppear, viewDidAppear and viewWillLayoutSubviews).
But the most weird, is that the status bar is in Landscape, over the Portrait ViewController!!!
(Of course, the problem appears both on device and simulator)
So if someone can help putting back that ViewController all in Landscape. Thanks in advance!
Well at last, I eventually found it!!!
The problem was (I still don't know exactly why) caused by the way I was switching between ViewControllers (the old iOS 3 way).
So to correct if, I test if the method presentViewController:animated:completion is available (God bless respondsToSelector:) and I use it when I can.
Problem solved!

iPad App Portrait Only?

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.

Xcode debug warning about two-stage rotation animation

My iPad app outputs the following warning in xcode debugger below using (gcc).
It's very frustrating because I don't know how to debug it.
Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations.
I do use following method for rotation changes
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration{
//with conditional statement like
if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
//change images for portrait, redisplay any visible popovers
}else{
//change images for landscape, redisplay any visible popovers
}
I'm not using any older two stage methods.
The app does use a root tabbarController with two viewControllers and one navigationController tabs in it.
Any help would be great.
May not be a real warning or an older version byproduct as I am not getting warning when I use a different mac with another iPad all running the latest xcode 4.3.3 and iPad iOS 5.1 (warning was on xcode 4.2 with iOS 4.3)
Also note these warning were only appearing when running on the device itself and not in simulator.
Hope that helps someone else.

IOS Device Orientation Stuck at Portrait mode, no Landscape

I'm using Xcode 4.3.2 and an iPad simulator 5.1
I really need some help with this, my app is stuck at portrait mode.
When I rotate the simulator
I've tried looking under the project settings and have these checked:
Portrait, Upside Down, Landscape Left and Landscape Right.
I also these methods in the view controllers:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
can anyone please help?
Check your supporting orientations in the project's settings or on *.plist file. Also, if you are using UITabBarController or smth else, all of your controllers have to support all orientations!
use cmd+shift+f and type - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
make sure all of them return YES if you want all orientations supported and NO For unsupported orientations
Make sure you only have one controller showing. I've seen this problem when I have multiple views with different controllers showing at the same time.
Yeah I had the same problem and the other answers here didn't fix my situation. I found I had to check the "Resize View from NIB" box in all the relevant views.
See screenshot below (although shows a slightly older version of XCode).

Resources