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. :)
Related
I'll try to keep this short and sweet. I have a universal storyboard and my application runs perfectly on the iPhone. I'm having an issue though where I have a view controller with 2 containers, which contain separate tableviewcontrollers.
On the iPad simulator the top table view controller works fine yet the bottom will not scroll or select any cells. Again, it works perfectly on the iPhone simulator.
I cannot for the life of my figure out whats causing this. Anyone run into something similar?
Thanks
Your view might be covered by another view. To make sure your view stays in the front, you can use
[self.view bringSubviewToFront:yourView];
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
I have a test app that uses a custom container controller to switch between 2 child view controllers based on the orientation of the device. In the portraitController, I have a button and a slider -- after one rotation to landscape and back to portrait, the slider still works but the button doesn't. After one more back and forth, both UI elements stop responding to touches.
Meanwhile, in the landscapeController, the button works fine for the first 6 times you switch to that controller, but on the 7th, the button only responds on the far left side, and on the 8th, it no longer responds at all.
The views look fine after the rotations -- everything stays in the right place. There's no methods connected to these UI elements I'm just seeing if they are responsive to touch. I have strong references to both child view controllers, so I am presenting the same instance on each rotation. I can post the code for the container controller if it would help.
Does anyone know what's going on here?
I found the answer after much experimenting -- the "Autoresize Subviews" check box in the container controller's view needs to be deselected. I'm not sure what that does exactly, but it was inappropriately resizing the views of the child controllers.
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
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.