I've Tab bar application and i will load the other view controller by navigation controller when i come back the tab bar is hiding i searched and i used
for(UIView *view in self.window.subviews)
{
if([view isKindOfClass:[UITabBarItem class]])
{
if(view.hidden){
view.hidden = NO;
break;
}
view.hidden = YES;
}
}
but the problem remains same can any one know the solution?
Thanks in advance
I am not sure what kind of result you want to achieve but perhaps you can check previous question to hide and display TabBar
How to hide uitabbarcontroller
If it doesn't work you can try to paste the code you are using to declare the TabBar
Related
My question is simple, How to hide back button in navigation bar? I see similar question here in stack overflow but
self.navigationItem.hidesBackButton = YES;
not working for me. I am using below code because RootViewController is my Singleton class.
Thanks
i still use both in viewDidLoad but both are not working
[RootViewController sharedFirstViewController].navigationItem.hidesBackButton = YES;
[RootViewController sharedFirstViewController].navigationItem.backBarButtonItem=nil;
Try self.navigationItem.backBarButtonItem.hidden = YES; or self.navigationItem.backBarButtonItem = nil;
Place one of these either in viewWillAppear:, viewWillLoad or viewDidAppear: of the class you want to get rid of the back button in.
I suggest doing this before the view appears on the screen. You probably dont want to see the bar and then have it disappear.
So you should call:
- (void) viewDidLoad {
//Check to see if the Nav har is hidden, and then hide it
if (!self.navigationItem.backBarButtonItem.hidden) {
self.navigationItem.backBarButtonItem.hidden = YES;
}
else {
NSLog(#"back button already hidden");
}
}
Note that you can also do this with the whole nav bar completely, if you're trying to free up screen space.
In my Main Window IB file I have a TabBarController and the first controller is a Navigation Controller. When I push my detail view (after pressing a cell in a table view) I want to push my detail view and display a tool bar instead of the tab bar. The problem is that when I try
tabBar.hidden = visible;
in my detail view controller (viewDidLoad) the tabbar dissapears before the animation between the first view and the detail view is done.
What i want to achieve can be seen in the native photo app when pressing on one of the images from a gallery. There the tabbar moves out with the animation of the first view.
How do I achieve this?
Thanks in advance
check out the 'hidesBottomBarWhenPushed' property on your detail's page subclass of UIViewController
either override this method
- (BOOL)hidesBottomBarWhenPushed
{
return YES;
}
or i'm guessing this would work the same:
self.hidesBottomBarWhenPushed = YES;
as far as showing the toolbar try:
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setToolbarHidden:NO animated:YES];
}
and on the way out
- (void)viewWillDisappear:(BOOL)animated
{
[self.navigationController setToolbarHidden:YES animated:YES];
}
In my application tab bar controller is used to show more than one views.I want to hide the Tab bar at the time of pressing first tab bar item.
But,I don't know how to do this...Plz help me to do this...
Thank You,
Renya
There are two methods in the tab bar control delegate protocol you should try:
– tabBarController:shouldSelectViewController:
– tabBarController:didSelectViewController:
You can hide the tab bar by calling calling tabBarController.controller.hidden = YES in the implementation of one these methods.
Note that the tab bar controller has two views; the tab bar and another view that contains the main content. I expect that you'll want to resize this content view too:
//remove the tab bars and resize the main view to fill the screen
UITabBar *tabBar = tabBarController.tabBar;
tabBar.hidden = YES;
UIView *mainView;
for (UIView * possibleMainView in [self.view subviews])
{
if (![possibleMainView isKindOfClass:[UITabBar class]])
{
mainView = possibleMainView;
break;
}
}
CGRect mainViewFrame = mainView.frame;
mainViewFrame.size.height += tabBar.frame.size.height;
mainViewFrame.origin.y = 0;
mainView.frame = mainViewFrame;
I am using some xib without tab bar and some with tab bar.
In starting i load the xib without tab bar-navigation bar then flow are working.But if i load a xib with tab bar-navigation bar then our all view slide bellow and half tab bar are not showing.Please anybody help me as soon as possible.
Pleaseeee!!!!!!
Are you loading a Tab Bar Controller or just a single Tab Bar? Is it happening right after pushing a view with a Navigation Controller? If so, the same happened to me (link here) and I have been unable to fix it. I think that it's something not supported and not recommended by Apple, you can find this in the NavigationController Class Reference:
viewController: The view controller that is pushed onto the stack. This object cannot be an instance of tab bar controller and it must not already be on the navigation stack.
What I did was to add a single Tab Bar (not a Tab Bar Controller) to the view that is being pushed, and then configure it programmatically. You can find a very good example in here (http://discussions.apple.com/thread.jspa?threadID=2099944&tstart=0), but it would be something like this:
- (void)activateTab:(int)index {
switch (index) {
case 1:
if (tab1ViewController == nil) {
self.tab1ViewController =
[[Tab1ViewController alloc] initWithNibName:#"Tab1View" bundle:nil];
}
[self.view addSubview:tab1ViewController.view];
if (currentViewController != nil)
[currentViewController.view removeFromSuperview];
currentViewController = tab1ViewController;
break;
case 2:
if (tab2ViewController == nil) {
self.tab2ViewController =
[[Tab2ViewController alloc] initWithNibName:#"Tab2View" bundle:nil];
}
[self.view addSubview:tab2ViewController.view];
if (currentViewController != nil)
[currentViewController.view removeFromSuperview];
currentViewController = tab2ViewController;
break;
default:
break;
}
}
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
[self activateTab:item.tag];
}
- (void)viewDidLoad {
[super viewDidLoad];
[myTabBar setSelectedItem:[myTabBar.items objectAtIndex:0]];
[self activateTab:1];
}
Of course you would need to declare your Tab Bar as well that the three View Controllers that are in use here (tab1ViewController, tab2ViewController and currentVideoController).
You don't give much details, but I hope this can help a little bit.
I am having some trouble with view hierarchies and drawing on the iPhone.
To be more specific, I have a tab bar application with a certain tab that contains a table view where I would like the selection of a specific cell to have a UIPickerView slide up. The sliding isn't really a problem (or at least I'm assuming it won't be once I figure this part out), but I cannot seem to get the picker (or any UIView, for that matter) to show up over the tab bar.
I think the way I have this certain tab set up may be the problem. Normally, in any other tab, I could just do something like this:
[self.tabBarController.view addSubview:pickerView];
and everything would work fine.
But for this specific tab, I have a UISegmentedControl in the navigation bar that switches between two different UITableViews. So the view controller associated with the tab (call it TabViewController) has its own instances of these two table view controllers (TableOneViewController and TableTwoViewController) and will insert the currently selected table view (based on the segmented control) as a subview of TabViewController's view.
If I didn't need to switch the views like this I could just call
[tabViewController.tabBarController.view addSubview:pickerView];
from TabViewController and the picker would show up over the tab bar. But the thing is I cannot call this in either of the table view controllers selected within this tab (well I can, but it doesn't do anything). I have tried passing this tabBarController property into the table view controller, but that doesn't work either. I have also tried messing around with the app delegate (which I'm trying to avoid) to no avail.
Is there something simple I'm missing here, or can this not be done? I feel like it should since a keyboard can slide up over the tab bar in this table view. Is there a way to just draw over all the current views and subviews?
Here is what is called when the segmented control is selected within TabViewController.m, and switches the views:
- (IBAction)switchViews:(id)sender
{
if (self.tableOneViewController.view.superview == nil)
{
if (self.tableOneViewController == nil)
{
TableOneViewController *tempOneController = [[TableOneViewController alloc] initWithNibName:#"TableOneViewController" bundle:nil];
self.tableOneViewController = tempOneController;
[tempOneController release];
}
[tableTwoViewController.view removeFromSuperview];
[self.view insertSubview:tableOneViewController.view atIndex:0];
}
else
{
if (self.tableTwoViewController == nil)
{
TableTwoViewController * tempOneController = [[TableTwoViewController alloc] initWithNibName:#"TableTwoViewController" bundle:nil];
self.tableTwoViewController = tempOneController;
[tempOneController release];
}
[tableOneViewController.view removeFromSuperview];
[self.view insertSubview:tableTwoViewController.view atIndex:0];
}
}
And here's what's going on when I try to add the picker in TableOneViewController.m:
UIPickerView *tempPicker = [[UIPickerView alloc] init];
tempPicker.delegate = self;
tempPicker.dataSource = self;
tempPicker.showsSelectionIndicator = YES;
tempPicker.clipsToBounds = NO; // thought this might work, but doesn't
self.picker = tempPicker;
[tempPicker release];
[self.view addSubview:pickerPicker]; // adds beneath tab bar!
[[[UIApplication sharedApplication] keyWindow] addSubview:someViewController];
Make sure the viewController you are loading in is 480px high!
To remove it again, use [someViewController removeFromSuperview];
Maybe you want to do just
[tabBarController presentModalViewController:someViewController animated:YES];
?
This should slide on top of anything else you have on the screen.