Strange UINavigationController Behavior in iPad app - iphone

I have an application with a UISplitViewController as the root controller. In the master side of the controller is the standard UINavigationController with UITableControllers inside. In the detail side is just a simple UIWebView.
I can get my UINavigationController to start exibiting some weird behavior after doing the following:
Rotate portrait
Bring up the master view by clicking my UIBarButtonItem
Navigate around in the master view by going into the nav tree and popping back out
Rotate to landscape
Navigate around in the master view just as before
When the UINavigationController is popped in step 5, the animated is all jacked up. The whole screen animates vertically down, instead of the the UINavigationController animating as usual. It seems to be very related to the UISplitController and rotation.
Anyone heard of this issue or know a workaround? I dont't think I'm doing anything advanced here. If I disable the animation of the UINavigationController, all works as usual, but I don't want to do that since the animation looks pretty slick when working properly.

To fix this issue you need to implement ShouldAutoRotateToInterfaceOrientation in all UINavigationControllers.
It is only an issue on iPad for some reason. EDIT: my case only failed on iPad, so this may not be true in other cases.

Related

UINavigationController with strange behavior

I am developing an application with the following structure,
Each of the three compoenentes has a UINavigationController associated with.
This application is intended to be identical to facebook.
My problem is that in landscape mode, the "POP" actions of navigations have a strange performance, making the animation from the bottom to the top, as if the navigation had not done the rotation, despite the layout being changed to landscape.
I put all the navigation controller with:
[navCenter.navigationBar setAutoresizesSubviews:YES];
[navCenter shouldAutorotateToInterfaceOrientation:YES];
Any idea why this happen?
Thanks in advance.
EDIT:
If i remove my
[self addChildViewController:self.mainConteinar];
The animation works good. But now, the NavigationBars didn't resize.
You should check all your
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
What you describe sounds as if you forgot to return YES for landscape orientation in one of your child view controllers.

Best practices for landscape only apps?

I'm a new iOS programming and I'm developing a simple iPhone game that needs to run in landscape only. I've ...
set supported orientations in the target settings
added the req. plist item (initial interface orientation)
overridden shouldAutorotateToInterfaceOrientation to return YES only for landscape modes
.. and the app "looks" correct, but there are a few odd things going on.
Issue 1 - I'm trying to manually position my views and not rely on autolayout. I've got a UIView in a NIB that I'm loading that needs to be positioned 150px from the right edge of the screen. I have to get the UIViewController's view's height (not width) to correctly position it - like it's not rotated to landscape at this point in the code.
Issue 2 - Implementing a UINavigationController to go from the title screen to the game interaction. When I'm pushing the interaction UIViewController to the stack, it slides in from the right like it's supposed to. When I go back to the title by popping the interaction, it slides UP to the title. It's seems like it's rotating back to portrait?
I think there is something very basic that I'm missing, but I can't find it in my app code. I've gone over the lists for a landscape app but they don't mention more than the list above.
Are there any other things/settings/methods to override that I should be on the look out for?
You need to set shouldAutorotateToInterfaceOrientation in your other viewControllers as well. Especially the ones displayed inside your UINavigationController.
Issue 2:
Don't use many UIViewController's. Use one view controller. Create one main UIViewController and for other UIViewController's just do:
[mainviewcontrl presentModalViewcontroller: child_viewcontrl animated: YES];
For delete a child view controller, use
[child_viewcontrl dismissModalViewControllerAnimated: YES];

iOS iPad start landscape, push VC, popVC, view has bad positioning

I start my app in landscape for iPad. A nav controller holds my tableVC I click on a cell we push a new VC onto the stack. That works fine. The problem is, when I press the standard "back" button on the nav controller, my app gets forced into portrait and my tableVC is off of the screen. I am doing no manual positioning of views. This doesn't happen if I start the app in portrait mode.
How do I fix this abnormal behavior?
Notes: There is also a tab bar present in the app if it matters.
Upon further testing, if I load the NavController in portrait (with the first view being the table view) then switch it to landscape, then select the cell, then press back, it works fine. So the problem only happens if i start the app in landscape and never turn it to portrait.
EVERY VC has shouldAutoRotate set to return YES. I have subclassed the tab bar and done the same. I am wondering if this is a bug. Perhaps the problem lies in the fact that I took existing .XIB files and their views that were created for iPhone, then copied and pasted them, then deleted the iPhone specific views and then added iPad views.
If your subclassed TabBar Controller returns yes, and ALL of your VCs return yes for shouldAutoRotate, then the problem lies within your xib files. Though your explanation makes it sound like the VC you are pushing doesn't return yes, you've stated that it does, so it must be the xib files.
In IB, try setting the default orientation of your xib views to landscape, clean - build and run.
That may provide a clue or two.
Maybe you can create a new and simple iPad application with just a tabbarcontroller a navigation controller and 2 viewcontrollers to test if the cause is or is not the recycled iPhone .XIB files.
Also you can Command+Shift+F to search in the whole project for ": UIViewController" to double check that every VC has shouldAutoRotate set to return YES, in case you have third party code in your application that has a subclass of UIViewController on it. (the search will return a list of headers files that inherits from UIViewController).
I had had similar problems with really weird behaviors that were fixed by deleting the .XIB file and made it again.
Good luck finding the problem =)

iPad : two-stage method implementation

here is my problem, I hope someone can help me.
My iPad app is made like this : I have several viewControllers added as tabs in a tabBarController added to window in my appDelegate. In each of these viewControllers I got two navigationControllers with one viewController in.
Appdelegate
TabBarController
viewController
navigationController
viewController
navigationController
viewController
viewController
navigationController
viewController
navigationController
viewController
Everything work fine in simulator but when I run it on device I got this warning :
Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations.
It only happen when I run it on a device in landscape mode. The first navigationController of the default view shown by the tabBarController take all the screen width (not important here but it's to explain that this warning makes my layout going crazy). In portrait nothing is traced in the console.
I read many things about this message but I can't find any solution to make it go away.
I'm sure it's a story of shouldAutoRotate or something like this.
I also notice that if i remove the tabBarController and simply add my first viewController to window, the message is not shown.
Very strange... please help :)
I think you should rely on the standard UISplitViewController available under iPad. This controller is what is used under the Settings app and various other apps.
If you do not feel comfortable with such a tool, you can take a look at the APSplitViewController plugin developed by slatvick on GitHub. This could solve a lot of your problems, I hope.
Edit
Googling about this issue, I found out that this warning appears when you create a wrong hierarchy of view controllers. In this case, you are pushing two navigation controllers inside a view controller, even if a view controller is not meant to contain different navigation controller. Probably there could be a problem related on how you send up to the parent view controller methods like viewDidLoad or viewWillLoad: etc. You should try to understand if you are passing all these call correctly to the parent view controller from the inner navigation controllers.

presentModalViewController for UIImagePicker fails in landscape mode for iPhone 3.0

First of all, my code isn't complex - in fact it's just two sample programs from "Beginning iPhone Development: Exploring the iPhone SDK", combined into one program. I took the ViewSwitcher application, which switches between a blue view and a yellow view, and replaced the YellowViewController with the CameraViewController from the camera application.
I have three ViewControllers total. SwitchViewController just switches between BlueViewController and CameraViewController.
Inside CameraViewController, I'm trying to use a UIImagePickerController to choose an image. The picker is presented with presentModalViewController. The catch is that I want to do this in landscape orientation.
Everything works fine under 2.2.1, and everything works fine in 3.0 in portrait mode.
In 3.0 under landscape orientation, however, things break. If I set SwitchViewController to landscape orientation, my screen goes white when I try to present the picker. If I rotate the iPhone a few times, I can see a corner of the picker, which apparently was displayed off screen.
If I set CameraViewController to landscape orientation, the picker doesn't come up at all.
I think this page may have a clue when it says "The most prominent change [in 3.0] I can see is that the modal view controller will always use the application frame instead of the parent view controller's frame." I don't understand exactly what that means, though.
Any help is greatly appreciated. Thanks!
I believe what that means is this: Modal views always use the full screen, even if the parent view controller that invokes them controls a view that is only part of the screen. This makes sense for standard modal views like the camera picker, but I can see why someone who creates a custom modal view might want it to be smaller.
Not sure if that really helps solve your problem though.
Question -- what happens if you bring up the modal view and THEN rotate the phone?
You must have used addSubview in your parent view controller, try using presentModalViewController:.