Where are the methods that defines allowed orientations? - iphone

I've been working on my app for a while, and it've been out in appStore for a while as well, but I now want to add support for landscape orientation. I've thought I had just unchecked the orientation-icons in the Summary-page of the target to only enable portrait, but when I check them now, nothing happens! A lot of stash has been added, but I can't find any methods that should disable landscape.. What kind of method would that be? I didn't find anything in appDelegate either.. I don't even know where to start looking.. When opening an empty project in xcode, they orient just fine with no methods at all..
In storyboard, when clicking a view and going to inspector, it says Orientation:Inferred. So the problem isn't here.
I using a tabBar, and all the views in the viewControllers are set to Autoresize subviews, as a similar question got answered.
EDIT
When enabling landscape for iPhone using the buttons in the target properties summary, the iPhone is allowed to go landscape, but when enabling it for the iPad, nothing changes..

shouldAutorotate in iOS6 and shouldAutorotateToInterfaceOrientation for previous version.
Note that the orientation is mostly defined by the ViewController.

you can add or remove the supported orientations in info.plist

I solved the issue by making a class for the UITabBarController, and setting shouldAutorotate... to YES. I find it weird though that my iPad storyboard overrode the Summary-page.
EDIT
This is giving me a hard time with everything else.. The device rotates correctly now, but sometimes when launched in landscape, it thinks it's in portrait.. Still trying to figure that out. Even when I ask the app which orientation the devices statusbar is in, it returns portrait even if it really is in landscape..

Related

Auto-rotation stopped working on iOS 7 XCode 5

In interface builder, I selected, copied, and pasted a textField, switch, button, and label from my iPhone Storyboard's Flipside view controller into the iPad Storyboard's popup view controller.
After that I started getting weird errors on those exact items, about frames that "will be different at runtime" that would not go away, and they did not have disclosure triangles to tell me what to do to fix it. I tried removing all my constraints to fix it, and that didn't fix it. Later I imply deleted those items which had been pasted into the iPad Storyboard and the errors went away.
But now auto-rotation does not work in my app. The status bar (time & battery indicator) rotates but nothing else does. Except sometimes it does, but when it does, it gets stuck in the landscape orientation and won't rotate back properly.
At one point also I did set the main view controller from "Intrinsic" to "Landscape" just to see how it would look in Landscape mode, but later I changed it back.
I feel like my XIB files must have gotten corrupted somehow... how can I fix this? I've tried deleting all my constraints and re-adding them, both manually and by the recommended method. Setting the thing back to Portrait and then Intrinsic and cleaning my build folder. Updating to the latest Xcode Beta (which claims to have enhancements for auto-layout and constraints, which has always seemed buggy to me, with the constraints menu somtimes refusing to pop up, etc.). But still rotation just doesn't work.
What do I do? Thanks.
The problem was caused by the fact that I was loading a UIAlert when the app launched. You could dismiss the alert but then the auto-rotation was broken. Once I got rid of the UIAlert everything was fine.
Weird.

GUI elements position in Xcode Storyboard differs from their position in the simulator

I recently worked with Xcode, especially with layout GUI elements. I read a lot of questions here about this, but it did not help me. What I have: ViewController, it lies ImageView, it lay all the other elements, I disable autolayout, screen size and in the simulator and in Xcode - the same (4 inches), but when I run I still see it:
What am I doing wrong, what is there is a way to what looks like a storyboard, and looked in the simulator (and real device) equally?
There might be two issues you are suffering with, please check following points for better understanding.
Check this with iOS 6 simulator. If its working fine then, you need to set ios 6/7 deltas for your subviews. Here is better explanation of it-- Interface Builder: What are the UIView's Layout iOS 6/7 Deltas for?
Check autoresizing masks of your subviews, definitely this is what affecting your views.
Good Luck!
Notice that in your Storyboard view, you have not displayed a status bar and that when running on the simulator, a status bar is shown. This is why all the objects are off placed. To fix this, you can either:
Hide the Status Bar - Call this method in your desired view controller:
- (BOOL)prefersStatusBarHidden {
return YES;
}
Show a simulated metric - Switch on the status bar simulated metric in your Storyboard:

UISplitView question and issues

I created a new project with a UISplitViewApplication. When you do this you will find a DetailViewController and RootViewController. In the DetailViewController there is a UIToolbar on top that resizes according to the orientation, whether it's potrait or landscape. I accidentally removed this UIToolBar and I dragged a new one from the FileManager window, however after connecting everything this new one doesn't resizes according to the orientation. Why is this?
Also one more issue I am facing is related to this orientation stuff. I added a UITextField and UITableView, etc in this DetailView, however when switching in between the orientation everything is just messed up. How can I prevent this? How do I make my view consistent no matter what orientation it has...
Have you looked in the measurements inspector to see how the struts and springs are set up for the toolbar, etc? A lot of times, you can use springs and struts to control how your UI will react to orientation changes. Sometimes, you have to do it in code.
If you're not sure how to do that, here's a link with some good info on this subject.
http://www.techotopia.com/index.php/IOS_4_iPhone_Rotation,_View_Resizing_and_Layout_Handling_(Xcode_4)
Hope this helps.
Jamie

How to trigger view rotation on new created view?

Simple question, hope there is a simple answer.
My scenario: iPhone app with NavigationController
Level 1: View with shouldAutoRotate..orientation=..Portrait (works)
Level 2: View with shouldAutoRotate..orientation=..Portrait (works)
When the iPhone is rotated, the views stay on portrait mode, perfect.
Level 3: View with shouldAutoRotate..TRUE (doesn't work on first load)
The first load of the view is in portrait independent of iPhone orientation and stays there, bad. After the view is ready, all rotations are recognized and work perfect.
Is there a way to tell the app "check your orientation now"? Several tricks I found didn't work (anymore) and the apple documentation seems less than helpful on this special topic.
So far the newest suggestion I found was to create a dummy view, show it and release it again, but I tried several places in the app and it didn't work. The view always gets stuck until you rotate the iphone manually. I would prefer a working example, so I can test it directly and see if it works before changing my code, but I'm also thankful for an explanation what to do if it works.
Thanks
//edit: As mentioned in one of the links this is considered a bug and not fixed by Apple, I worked around the problem replacing the NavigationController with own Controllers each with a Scrollview. Not very nice when you have all running and just need the rotation to work as expected, but works at least as expected. Thx to occulus for pointing in the right direction.
Please see this question:
Transitioning to landscape rotation within a uinavigationcontroller
Also:
UINavigationController and autorotation
So a good strategy might be to use Modal dialogs.

upgrade to universal app - size of mainWindow-iPad is 320x480

I have the following problem.
I have an iPhone app and want to upgrade to universal
When I do this, I get the expected MainWindow-iPad.xib.
But the size of the window is hardcoded to 320x480.
Also, there is no view in the window.
I red, this should be automatically iPad-sized, so I am assuming I am doing something wrong.
What exactly am I missing ?
thanks in advance
Yes, the dimensions of a UIWindow object are hard-coded to the size of the iPhone screen. This confused me, too, until I realized there was an option to resize it: select the UIWindow object in the .xib in Interface Builder... in the Attributes pane, make sure the "Full Screen at Launch" checkbox is checked.
As St3fan says you'll probably want to have a specific main window .xib for your iPad build.
See my answer at:
UITabBar unresponsive on iPad
I got this. I fixed it by deleting the automatically created ipad xib, then opening the original xib in interface builder and choosing convert to iPad from the menu. Then ni saved it with the -iPad name and added it to the corredt target.
You will probably also need to create a MainWindow-iphone.xib and MainWindow-ipad.xib.
I had a similar issue with a GLES application - using EAGLView, in a manner similar to all of the samples, but wanting to support iphone3,iphone4,and ipad.
in my context creation from [EAGLView initWithCoder], I was forcing the eaglLayer's rect to match the main screen, which worked for iphone and iphone4 (i.e. gave me a 320x480 or 640x960 gl surface), but for ipad, this gave me a 768x1024 surface which was cropped on present to 640x960.
As it turns out, The "Full Screen at Launch" option seems to be applied AFTER the view's (EAGLView, in my case) initWithCoder.
My solution was to do nothing in the [EAGLView initWithCoder], and only actually initialize my view after the AppDelegate's didFinishLaunchingWithOptions gets called, in the layoutSubviews call.
HTH,
forks