Transitioning to a view does not respect orientation - ios

I had a bug where I would call to transitionWithView and the new view would appear in Portrait while my app and all XIBs are only marked as Landscape as well as the origin view.
I found how to fix the problem thanks to this question (+1) :
I would like to understand though ( and it is not explained there ) - why does it behave this way ? Where in the application is the orientation stored, when is the view notified about the orientation and why views which are transitioned to are unaware of the orientation vs views which are added using addSubview...
Searched a lot but did not find clues .
thanks

Related

UISplitViewController - Wrong detail view sizing

I’m maintaining a universal iOS App whose development has started on iOS 6. I’m about the renew the UI for iOS 7. Now I’ve got a weird problem with the iPad part of the app. This part follows the „normal“ Master-Detail view pattern using a UISplitViewController. The UI is configured in a storyboard. The UISplitViewController is the root view controller as requested by Apples docs.
Here comes the weird part: When the detail view controller is embedded in a UINavigationController the navigation controller will be sized incorrectly by the UISplitViewController and so the whole interface looks broken. It appears as if the navigation controller remains in portrait orientation even if the device orientation is landscape. In portrait orientation the detail view controller is looking fine though.
If I avoid embedding the detail view controller in a navigation controller and connect it directly as detail view controller with the UISplitViewController everything is working perfectly in both orientations.
I tried to reproduce the problem in a simple sample App based on the Master-Detail project template provided by Apple without luck. There it works even with a detail view controller embedded in a navigation controller. No matter what I’ve tried so far (looking for categories interfering, rotation settings, method swizzling etc. pp.) I couldn’t find the cause for this problem. As I’m running out of options (if possible I’d rather avoid rolling my container view controller) I respectfully ask if anybody around here has a solution to this problem or further ideas on how to track down the problem.
Thanks in advance
Tino
Found the solution to my own problem. I created a category on UISplitViewController and added a method 'detailViewController' only meant to be a convenience method to access the detail view. Unfortunately the UISplitViewController has an equally named internal method which is was replacing. Would I have followed Apples guidelines to always prefix category methods in order to avoid name clashes I would have saved a lot of my own time. :(

Portrait and landscape orientation on storyboards without auto-layout

I'm using storyboards and need to create to different views for portrait and landscape layout. I can't use auto layout in this case because I need to completely rearrange things in some cases.
I found a solution to use two different views and hide or show it depending on the device orientation but it doesn't work very good for me. I have a lot of outlets that I need to connect from xcode designer to code, and it seems that I can't connect two diffrents objects like for example two different buttons to the same IBOutlet. Can I? When I did this only one was really working. Moreover this solutions doesn't seem so efficient.
I took also a different approach and created two different view controllers which I load according to the device orientation, but there's a problem when for example I turn off application change orientation of the device and turn on it again and come back to a view controller that was in the beginning of the navigation stack, then it has an orientation that it has before.
Anyone has some ideas how to solve this problem?
You should only use one ViewController and one view and kind of hard-code the positions of the elements. Like (pseudocode)
if (orientation landscape)
label1.frame = ...
else (orientation portrait)
label1.frame = ...
Maybe you can group parts of the layout within another UIView (select the elements and go in Xcode->Editor Menu->Embed->View. Then connect the new view to the ViewController and push it where you need it.
Take a look at this answer, maybe it helps

iOS Orientation messed up on connection to UIViewController.view

I have 2 UIViewControllers in my app, and 2 views. 1st view is black, 2nd view is white.
The orientation is landscape mode, and the main (1st) view works ok.
So I created a second view controller, made the orientation in ib for it landscape, and connected the 2nd view to it via IB.
I realised that the moment I connect the view, the orientation is messed up. It seems like the app is displaying the 2nd view in potrait mode instead. But nowhere in IB are my views in potrait mode.
I should get this. (I can get it by disconnecting the 2nd view from the 2nd viewcontroller, but that's not really what I want.
But I am getting this.
This should be straightforward but it seems like it's not.
How do I fix this? I've tried putting
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight|UIInterfaceOrientationMaskLandscapeLeft;
}
in both viewControllers but it doesn't help. Any ideas?
It was the autoresize mask.
Somehow if the arrows are not selected I get the undesirable result. It's fixed but I'm not quite sure why.
I'll be glad to accept the answer for anyone who can explain this to me. :)

AQGridView orientation change has no effect

I'm fairly new to ios programming and am implementing AQGridView in a project I'm working on.
I've noticed the example applications provided seem to be able to handle orientation changes and regroup the cells accordingly.
In my application, the AQGridView appears in a UINavigationController stack. Any views prior to the one with the AQGridView handle orientation changes fine and adjust content based off the orientation.
However, once my app reaches the view with the AQGridView it seems to get stuck into portrait mode. Any change of the orientation does not seem to do anything and the AQGridView does not regroup the cells.
I've looked into the source code of the example apps and can't see any difference in implementation to my app.
Am I missing anything here? Is there anything special I need to do for AQGridView to support orientation changes and regroup the cells?
Turns out it was a problem with UITabBarController.
If anyone is having the same problem as me, I'd suggest looking at all the root view controllers for the UITabBarController.
Make sure the following method returns YES for all the view controllers or autorotation will not work.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

How to properly switch UIViews

I want to have multiple views in my application that I switch between.
What is the proper way to switch between UIViews that also supports UISplitViewController?
Is there a support way to switch or are Apple's controller classes designed to be root and root only?
I've tried having one root view and root controller and swap subviews in and out. One of the subviews is a UISplitViewController. It did not like the arrangement and does not display correctly. The detail view was not displayed, the master view displayed wrong orientation and wrong size.
I've then tried managing adding and removing one subview from the UIWindow in the app delegate. This works most of the time. However, the views added after the applicationDidFinishLaunching method do not appear setup correctly. They mostly look correct, however sometimes the orientation thinks its portrait when in reality its landscape. Also, when I try to display a popover, it shows up in an incorrect location. If I change the orientation, it redraws correctly. I've also have some random instances where the UISplitViewController view does not fully display, as if its frame is incorrectly sized.
Any suggestions heartily appreciated.
In applicationDidFinishLaunching, your objects haven't completed loaded from NIBs yet. Try using a viewDidLoad method instead.
What is the user-interface for switching between views? If one of these views represents a transient mode that the user enters and then exits, consider using a modal view. (See presentModalViewController:animated:.)
I would need more details about what you're doing to answer more particularly.

Resources