Push UIViewController to UITabBarController - iphone

I have UITabBarController, which has four tabs. When moving from another UIViewController to one of the view in UITabBarController, bottom Tab Bar item is not appearing and also there is space at the top and bottom of the screen. How can I avoid that. I am using storyboard.
Here is the code I am using, while moving from UIViewController to UITabBarController:
HomePage *mvc=[self.storyboard instantiateViewControllerWithIdentifier:#"HomePage"];
[self presentViewController:mvc animated:YES completion:nil];
mvc.hidesBottomBarWhenPushed = NO;

Hmm, if you're moving to a UIViewController in UITabBarController it will be messed up. What you need to do is move to the UITabBarController and set it with the correct UIViewControllers with setViewControllers:animated:
So set a segue to the UITabBarController and use setViewControllers:animated: and put your UIViewController in the array as parameter to setViewControllers:animated:.

Is the space the only problem that you have?
1.) Make sure that the UIViewController in storyboard/ib has the same imitated UIItems (Bottom Bar, Navigation Bar, Status Bar) that are displayed on runtime.
Doing so you can fully utilize the available space. Plus the associated view will have the correct size.
2.) Have an eye on the autolayout option and settings. Depending on what you do in detail you can end up with what you describe or with a view that smoothly fits into a larger or smaller superview - as far as possible.

Related

UISplitViewController transition from top to bottom instead of right to left

I have a root UISplitViewController that contains a UINavigationController related with a DetailViewController. The DetailViewController calls, via a storyboard push segue, another ViewController, called SecondViewController. When the user clicks on the Back button in SecondViewController toolbar, all the UISplitViewController has a transition from top to bottom, instead of a right-to-left transition of the DetailViewController. In the xCode designed all the transition style properties are set as "Flip horizontal". Is there a way to solve it?
I had the same problem in ios 5, landscape orientation.
Adding shouldAutorotateToInterfaceOrientation: both in Master & Detail controller solved problem
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}

Hidden UITabBar still crops any UIView that's put on top of it

I've been trying to add a UIView (with a UIImageView) as an initial screen when the user launches my application for the first time. However, even after I hide the tab bar, or move its frame out of the screen, the UIView still crops itself as if the tab bar was still there.
Both of these code blocks produced the same result:
[appDelegate.tabBarController.tabBar setFrame:CGRectMake(0,1000,0,0)];
[self setView:InitialView];
and
[appDelegate.tabBarController.tabBar setHidden:YES];
[self setView:InitialView];
Here's a screenshot of the incident in action:
Does anyone know how to fix this problem? I've been puzzling away at this for the past few hours, and I can't seem to do anything about it.
Presumably you have your view's view controller inside this tab bar controller. As a result, the view controller's view is getting sized appropriately to fit inside the tab bar controller's view. Why don't you just get the frame of the tab bar and adjust the height of your view by the view's current height + the tab bar's height?
As a side note, I am assuming InitialView is a UIView (or subclass) instance. It is standard Object-Oriented Programming convention to name instances of classes with a lower case letter, and then to proceed in camel case, as in initialView. Just an FYI.
Try this reference your App Delegate which should take in account the UITabBarController. Just the UIImageView as a subview, and when you are done just remove it. You'll obviously have to import your AppDelegate.
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication]delegate];
[imageView addSubview:appDelegate.window];

Iphone UIViewController to UINavigation controller programmatically

I have been stuck on this for a few days now and it is killing me... In my viewDidLoad event, I am trying to programmatically add a full screen UINavigationController to a subview of my view controller. So far, I have only succeeded in doing two things...
1) Only a grey screen shows up
OR
2) I get something that resembles a navigation controller added to the view controller, instead of being my navigation controller from a XIB it is just a generic one... even though I loaded from the XIB. Oddly enough it is always shifted 25 pixels downward and slightly cut off.
I have read every single link on google and I can't seem to figure this out. I just created a new viewcontroller... added a UINavigationController to it... try to load that view controller and it messes up.
Any help is greatly appreciated!!!!
Instead of having the UINavigationController be a child of some other view controller, make the UINavigationController the root controller itself. The navigation controller is one of the special "container" view controllers, and it generally wants to own the whole screen and be at the root of the controller hierarchy (except in certain circumstances).
Try something like this:
UINavigationController * rootNavController = [[UINavigationController alloc] initWithRootViewController:myRootControllerInTheNavController];
[window addSubview:[rootNavController view]];
Which will obscure any existing views with the nav controller (those existing things will still be there when you -removeFromSuperview the nav controller's view). The nuclear option is to set your UIWindow's rootViewController property with the nav controller, but it sounds from your comment that this may not be what you want to do here.
Possibly a cleaner approach: If it accomplishes what you want, I believe you could also take your nav controller and present it modally (see docs for uiviewcontroller) from whatever the current view controller is. Set the transition appropriately, and while you're in the nav stack, the nav controller will be visible.

iPhone landscape navigation back action shows vertical view transition?

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!

Switching Views within UITabBar View

I have created an UITabView application. Each view selected from the bar is a seperate controller with own nib file. I switch between them succesfully.
In the first view I have two buttons (check out the screenshot). When clicking them I want to switch to another views which are the parts of the current view controller. I use:
[self presentModalViewController:anotherViewController animated:NO];
That switches the view, but hides the UITabBar. How to keep the bar on the screen after the switch?
P.S. Sorry for the blurred image. I am not allowed to share to much info.
Well I think you are misusing the modal view controller. For a problem like this I'll say you should put them in a view controller stack using UINavigationController. Instead of making each tab a UIViewController make it a UINavigationController, then you can push and pop view controllers on it, which still show the tab bar.
See http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UINavigationController_Class/Reference/Reference.html
use: tabBarController.selectedViewController = newViewController
edit: UINavigationController is not needed here.