I have a regular UINavigationController and I push a series of UIViewController into the stack. The view transition for push controller is horizontal animation transition:
[self.navigationController pushViewController:controller animated:YES];
However, when I press the Back button on the navigation bar, the view transition animation is vertical (vertically dropping down the previous controller/view).
I don't seem to find any way to make this horizontal. This happens only in Landscape mode. Portrait mode the transition all happens as horizontal flip transition.
Can anyone shed any light on this?
Thanks
I had the same problem. When I pressed back to get to the first view I saw a vertical animation instead of the normal horizontal one.
I found an answer based on Apple's NavBar sample code. I edited the sample code to add "shouldAutorotateToInterfaceOrientation" to all the view controllers, and made it return YES.
When I ran it I noticed the correct animation was used when pressing "Back".
FIX:
It seems like you need to use your own subclassed UIViewController within the navigation controller, and add shouldAutorotateToInterfaceOrientation. Presumably the default UIViewController isn't returning the correct orientation so the wrong animation is used.
BACKGROUND:
I checked all the differences between my code and Apple's, and I found out that my navigation controller was a subclass of UINavigationController, where I perform all the work. By default IB had added a UIViewController inside this, and I left it alone. I noticed that the NavBar sample code had its own class set (MainViewController). So I made Xcode create a new UIViewController subclass with no xib, then set it up in the Class option in the Identity panel in IB.
I hope this makes sense and helps!
Related
I have a UINavigationController which was created in Storyboards, and connected with push segues for each view controller. However, when I click "next" (which activates the push segue), then animation going forward is strange. (See: https://www.youtube.com/watch?v=0cFo9sUtBeM). Going back (Selecting the root controller of the UINavController in the UITabBarController) has the correct animation though. Any ideas why this could be?
Edit: the boxes in the video are added by me to protect client identity. The animation issue detailed is the slide animation which appears to come from the top right (or top left for the 'next' button).
It appears that setting a different Prompt for the navigation bar on the second view controller causes this weird animation effect. After removing the prompt, the animation now works as expected.
It looks like a navigation controller push and a modal transition. If I had to wager, I'd guess you have a modal transition hooked up to the button in storyboard, and code in the action method for the button doing a pushViewController:animated: on self.navigationController - (either that or the other way around, with a push hooked up in storyboard).
If that's the case, start by commenting out any button action code (any target/selector you setup in code, or any IBAction you setup in storyboard for that button).
I also recently had this problem using a Master Detail storyboard with an embedded Navigation Controller. The issue was fixed when I changed the Background of the View of the Detail screen from Default to a different color. I found it did not make any difference which color as long as it was not Default. I hope that this helps someone.
I am facing few problems while using tabBar with navigation controllers.Each tabBar item is associated with a separate navigation controller.Problems are listed as follows:
1.There are more than five tabBar items in my tabBar so a more tabBar item comes by default.Now when i tap the more tabBar item the remaining items come in a tableview which is actually the view of a navigation controller(which comes by default).Now when i select any of the row, my new view controller gets pushed into that navigation controller.I want my view controller to be the navigation controller.So there is a situation like pushing a navigation controller onto the sack of another navigation controller.The compiler gets confused and it does nothing.
2.Although I have set autoresizing of each controller of tab bar controller nothing happens on rotating the device.However when I keep only five or less tabBar items,autoresizing works perfectly.
3.I want an ImagView at the top throughout the application, so I attached an imageview on the window itself and than increases the y-coordinate of the tabBar controller's view so that the navigation bar of each tabBar controller's view starts just below the imageview.Everything is fine for the portrait mode but as soon as i rotate the device the imageview dissappears.And when i again come to portrait mode the imageview does not appear and the tabBar controller's view starts from the top.
I tried it every ways(like tabBar instead of tabBar controller etc.) but fail to achieve anything helpful.
I've never heard of that problem before. Can you paste some code? Also, are you sure that the tabs on the view more page work correctly?
In order for a TBC to rotate, all of the root view controllers of each tab must support rotation. In each of those files make sure shouldRotateToInterfaceOrientation: returns YES for all orientations (if you're using the default iPhone VC template take out the if(interfaceOrientation == UIInterfaceOrientationPortrait) statement and associated brackets).
I've actually done this before, and trust me when I say you're opening up a can of worms. To achieve this you need to add the TBC as a subview of a view that has an imageview on top. You must manually set the TBC.view frame to not cover up the top image. The best way to do this is: in the .xib for the container file, add an image view up top, and under it another view. Connect the view to the code via an IBOutlet, and set that frame as the TBC.view.frame. Then add the TBC.view as a subview programmatically.
With this solution, however, you must add in a willRotateToInterfaceOrientation:duration: method that calls the same function in all the TBC's viewcontrollers, and all of those viewcontrollers must be navigation delegates that call viewWillAppear: and viewDisappear: manually. The rotation is also a bit "sticky" when you do this, so beware.
My suggestion: don't put a static image up top. It causes a lot of issues, and takes up a lot of screen real estate, especially on the iPhone's smaller screen. Look at The Weather Channel app if you want to see how bad it looks.
Let me know if you have any more questions!
I have an app built from the UITabBarController starter project. The first tab is part of the main.xib that contains the tab bar. I would like to slide a view up from the bottom on top of that tab's view that only covers part of the screen. My understanding is that you can only cover part of the screen if you make the top view non-modal, but I don't see a way to do that without a NavigationController.
How can I do this?
you can add a UIView as a subview to the current view, and then animate its appearance into the screen using animation blocks, or Quartz or however you would like.
presentModalViewController: is actually a method that belongs to UIViewController, the superclass of UINavigationController, so you can use it from any view controller, not just a navigation controller.
Have you tried using a UIActionSheet? That's an easy way to get a view with a few buttons for user input to slide up and only cover the bottom portion of the current view.
i need to shrink the height of a UINavigationBar (attached to the UINavigationController)
i've done this via the UINavigationControllerDelegate's navigationController:didShowViewController method, and it's working fine.
the problem is the visible viewcontroller that's in the main view. it wasn't resizing itself to reflect the new navbar height. thus, the didShowViewController method also resizes the viewcontroller's view frame, which works fine.
however, when i go to push on a new ViewController, or pop, i always see the view shift down to the original position during the animated transition to the next view. then, due to the code i have in the didShowViewController in the NavControllerDelegate, it shifts it back up.
i'm curious as to the best way to ensure that the shift down never happens.
i tried placing the code that resizes the frame into the willShowViewController, but that doesn't do anything.
i've also made sure that the UIView's frame that is the view of the UIViewController that's being popped, is also of the proper/shifted dimensions. no go there.
it's like i need to intercept the drawing actions after the pushViewController is invoked, and before the UINavigationController's didShowViewController is called.
i've been staring at my code for hours & hours... not getting anywhere. hopefully this makes sense to someone out there.
thanks!!!
Another option I think would be to set the NavigationControllers navigationBarHidden equal to YES. This will hide the nav bar completely and then you can then draw whatever view you want in the place the bar would have resided. Just put controls on the view that wrap the navigation methods (push, pop, etc...). It might be a challenge to get it to have the same style as a nav bar though.
I have a UITabbarController with (so far) two navigation controller items. I can get the application to rotate by adding the shouldAutorotateToInterfaceOrientation to each class... but thats not exactly what I want.
What I want to do is to add a button in the UINavigationBar in one of the classes. When this button is pressed I want it to load another view into landscape mode. This view should not show any navigationbar or tabbar controller.
How can I get this to work?
Best regards,
Paul Peelen
You can try to use approach similar to Apple's AlternateViews sample.
Basically you should:
Create your landscape view with appropriate size (480x300 for landscape if standard statusbar is visible)
In your button handler push your landscape calling -pushModalViewController on your current view controller
Apply necessary affine transformation to your view to be displayed correctly in landscape.
Use presentModalViewController:animated: and implement the modal view controller's shouldAutorotateToInterfaceOrientation: accordingly.