xCode: setView always portrait though device in Landscape - objective-c

I have encountered a problem developing an iPad app with xCode.
When I load a view into my rootViewController like this
[self setView:viewController.view];
The view is always displayed in Portrait even though the device is rotated to landscape.
I checked all options and tried changing the shouldAutoRotateToOrientation method and it seems to have nothing to do with it.
If I rotate the device to portrait and then back to landscape it works.
Does anybody know why this is happening?
Best regards,
Matteo

The problem was that I was nesting viewControllers which leads to bad behavior like rotation notifications not being sent to certain ViewControllers.

Related

lock a view to launch initially in landscape (ONLY landscape) objective-C

I want to initially launch one of the View controllers in JUST landscape mode, while the other views and the whole app can work in both portrait and landscape. How can I do it in iOS 7? Thank you.
So your whole app may supports all orientations but one view controller needs to be landscape only.
You can easily stop your landscape view controller to rotate from landscape to portrait but when the app is in portrait already then it is difficult to force the deivce to rotate as this contradicts the iPhone manufacturers priciple.
In fact, it is not really difficult when you know the trick. See my answer to this similar question.
Force controllers to Change their orientation in Either Portrait or Landscape

UIViewcontroller's view frame starting at unexpected location

We are started to convert our iOS 6 application into iOS 7. I tried to create one screen for my application. I used Xib file for design, I designed the screen from top to bottom with UILabel and UIButtons. When I tried to run the app in Simulator it showing differently from xib design. In simulator the designs are came down and bottom UILabel has hide.
I got the self.view.frame from viewDidLoad() was (0,64,32,504). But, it is showing correctly in viewDidAppear (0,0,320,568).
How can I resolve this issue in Xcode 5? Could you please help me to solve this.Looking forward your reply. Thanks.
You cannot depend on the frame in -viewDidLoad, because it hasn't been resized for the device at that point. You need to wait for -viewDidAppear.

Need only tab bar in portrait mode and all viewControllers in landscape mode

I am developing an iOS app in landscape mode, except that I need the tab bar to be on the right side(vertically). I was wondering if I could display all the viewControllers(navigation driven app) in landscape mode and only the tabbarController in portrait mode?
In other words, can I set the orientation of all viewControllers to landscape mode and set orientation of only the TabBarController to landscape mode so that I can affectively make it appear on the right side?
Any pointers are greatly appreciated.
Thanks much!
This is probably not the answer you are looking for, but I would highly recommend to open the UITabBarController & UITabBar headers to get an idea on how a tabbar is implemented, and start creating/subclassing your own, instead of hacking the existing components together. You'll need at least a viewcontroller, an array to retain the viewcontrollers represented by tabs, a view to display the active viewcontrollers view and a pointer to the active viewcontroller.
The learning curve for writing your own viewcontrollers is much higher, but trust me, it is worth it.

iOS Face Up Orientation Issue

Is there any way to differentiate between landscape and portrait when the device is sitting on a desk, i.e. UIDeviceOrientationFaceUp? I have two different xib files that I switch between based on the way the user is holding the device. But the problem arrises when I hold the device in landscape, and then place the device down. The device remains in landscape, but will load the portrait xib file. The problem would be opposite if in my coding I coupled the UIDeviceOrientationFaceUp with the landscape orientations: then I would have my landscape view showing when the device is still in portrait.
Is there any way to be able to figure out if the device is still showing landscape or portrait? I have tried checking frame width, but it claims it is 768 even if the device is sitting flat in landscape. And I can't force an orientation when the device goes flat, I hear thats the road to rejection on the App Store.
You can't do that. The accelerometer can't tell on which side of the phone the user is sitting when it's laid down on a table. You can measure rotation around it's axis using the gyroscope (and the compass), but that still doesn't tell you where the user is unfortunately.
There is one way to check it.
UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice] orientation];
UIInterfaceOrientation statusBarOrientation =[UIApplication sharedApplication].statusBarOrientation;
Use the first one to check if the device is in faceup and second one will tell you if the device is in portrait or landscape.

iPad orientation

I have question regarding changing orientation on iPad.
I use MonoTouch, but if Obj-C programmers can help, it will be just as great.
First of all, I figured out if I provide different splash screen images for different orientations, app will show the right one. This can be done for any orientation, such as "Default-LandscapeLeft.png", or generic one "Default-Landscape.png".
All of my images are of correct dimensions and yet, when I start it in portrait mode, it shows it enlarged. All of other modes work perfectly well.
Second problem is I want my app to continue to be in that orientation after my first controller appear. At the moment, it shows portrait in any case. I started generating orientation notifications before first controller appeared (UINavigationController), but I think it responds only on orientation changes. After I moved device, it rotates and from that moment, everything works fine. BUT, I want to "inherit" orientation info from my splash screen.
Any idea will be appreciated.
Thanks guys and girls.
Cheers
Images for different orientations:
Default.png and Default-Landscape.png should be provided + setting the app settings to provide the required orientations.
Second problem:
After creating the first controller call
myController.WillRotate(UIApplication.SharedApplication.StatusBarOrientation, 0);