i am making an application in iphone in which i have 4 tabbars & in one of its tab i have 4 views in 2nd view it needs to hide the tab bar. I am able to hide the tab bar using the setHidesBottomBarWhenPushed:YES in in the initWithNib method of the Viewcontroller being pushed. But when navigating to the screen 3 , calling the same method with "NO" does not make the tab bar appear. any ideas?
John Smith is correct. The URL for that sample is: http://developer.apple.com/iphone/library/samplecode/TheElements/index.html
The code that does this is in AtomicElementViewController.m, and the line that achieves this effect is in the init method:
self.hidesBottomBarWhenPushed = YES;
I had the same issue to show or hide tab bar controller with UITableViewController customized class. Somehow, by using the following codes, does not work to hide tab bar controller:
- (void) viewDidLoad {
self.hidesBottomBarWhenPushed = YES;
}
In the case of storyboard with segue, initWithStyle: method does not get called.
Instead, I have to overwrite the property to make it work:
- (BOOL) hidesBottomBarWhenPushed {
return YES;
}
My case is for iOS 5.1 with storyboard and segue to push to the next view (where I want to hide tab bar controller).
Take a look at Apple's Elements projects. They hide and unhide the tab-bar when you view and individual element.
Before you push your 3rd view onto the stack, set the 2nd view's hidesBottomBarWhenPushed to NO.
Related
I have built an app based on a tab bar controller. While I am on one of the tab views I want to be able to swipe my finger and switch to another tab view of which the index on the tabBarController in unknown. I am therefore calling the desired viewcontroller from its nib. The view gets swapped correctly but the problem is that it appears ABOVE the tab bar itself, covering it completely and making it become unusable! How can I push the view back or the tab bar up? Thanks
- (IBAction)swipeLeftDetected:(UIGestureRecognizer *)sender
{
DesiredViewController *controllerInstance =[[DesiredViewController alloc]initWithNibName:#"DesiredViewController" bundle:nil];
controllerInstance.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controllerInstance animated:YES];
}
presentModalViewController:animated always uses whole screen: On iPhone and iPod touch devices, the view of modalViewController is always presented full screen. On iPad, the presentation depends on the value in the modalPresentationStyle property.
If you really use UITabBarController, it instantiates view controllers of its tabs. So trying to instantiate view controller of one of tabs manually is wrong. You will end in a mess of view controllers instances.
Set property selectedIndex of your UITabBarController to switch tab. I think you need this. But it will be switched without animation.
If you know only pointer of controller you want to switch to, ask viewControllers property about controller's index and than switch tab by its index:
self.selectedIndex = [[self viewControllers] indexOfObject:viewController];
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);
}
I am using a Navigation Controller. On top of the AppDelegate window I added a view that contains a scrollview and toolbar that I want to be using throughout the app. They appear fine on all the view controllers that I am using in the navigation controller. Now I would like to be able to hide and show them from each view controller.
I can't figure out how that should work,
any suggestions?
I am not sure if I understand you correctly but if you just want to hide/show scrollbars in each viewcontroller just call:
myScrollView.showsVerticalScrollIndicator = NO;
myScrollView.showsVerticalScrollIndicator = NO;
in init, viewDidLoad or any custom method in your UIViewController subclasses.
I want to hide the bottom toolbar on a certain screen in my application, and IB seems to have an option for that which seems to preview as working correctly, but when I build and test the application the bottom toolbar is still there.
I know that I can use [self.navigationController setToolbarHidden:YES]; but my question is not how to do it using code, but how to get this to work through Interface Builder.
Here is a screenshot of what I am talking about. See on the right how I have selected Bottom Bar: None - this removes the bottom bar as previewed to the left. If I set it to inferred (instead of None) the bottom bar shows in the IB preview.
How do I get this to work correctly?
You can't set this in Interface Builder. If you notice the header of the section in IB where you can turn on/off these different bars, it says "simulated". These options are only there to help you visualize your UI in IB while designing it. They have absolutely no influence on the running app.
I couldn't do it in storyboard when you just want to hide toolbar in one view controller. If you want to hide it for all, you need to go to the navigation controller, and set the values in the storyboard. But this makes all of your view controllers to hide the toolbars. If you want to hide it for one view controller use this in that view controller:
-(void) viewWillAppear:(BOOL)animated
{
[self.navigationController.toolbar setHidden: YES];
}
-(void) viewWillDisappear:(BOOL)animated
{
[self.navigationController.toolbar setHidden: NO];
}
Enable "Hides Bottom Bar on Push" within the IB in case your ViewController is pushed onto a UINavigationController stack.
This should exactly do what you are asking for. As a bonus, the hiding and showing will be nicely animated by the system.
I have made an application in which I have four tab bars. I have used the below code to go to the second view in a button's click method. It goes to the second view but the second view is not showing with tab bars. How can I fix this?
- (IBAction)Existinguser:(id)sender
{
ExistingUserViewController *existingUserViewController =
[[ExistingUserViewController alloc]
initWithNibName:#"ExistingUserViewController" bundle:nil];
[self presentModalViewController:existingUserViewController animated:YES];
[existingUserViewController release];
}
Presenting a view controller modally will show that view controller above all ther other UI elements (this includes the navigation bar and tab bar, but not the status bar).
If you want to show your "second view" as the view on the second tab, then you need to set the view controller you want to use as the second tab's view controller. That way when you press the second tab, the second view controller will be shown, and the second tab will be selected and visible.
I might be mistaken, but do you have a single tab bar with four tabs and you are looking for a way to change to the second tab? You can do this with the following code:
self.tabBarController.selectedIndex = 1;
btw the code you attached to your question is displaying a new model view controller above the current view controller. This is the reason no tabbar is shown.
If you are trying to create a navigation based app using tabbar, in IB, change the tab's viewcontroller to UINavigationController. You can then use the UINavController methods to navigate between views. In case you don't want to show the navbar, just set that property in IB.
Here's a good example of how you can use tab bar with navbar