Firstly,I'm using Xcode 6 and Objective-c. I want to change tab bar screen with button or automatically with code how can i do this.Another question may i do this different view not a item of tab bar controller.
- (IBAction)backButton:(id)sender
{
ProfileSide *vc = (ProfileSide *)[[self.tabBarController viewControllers]objectAtIndex:1];
[vc.view setNeedsDisplay];
[self.tabBarController setSelectedViewController:vc];
}
I tried this code part but not working. ProfileSide name of the class 3rd item tab bar controller.
ProfileSide *vc1 = [self.storyboard instantiateViewControllerWithIdentifier:#"meScreen"];
[self presentViewController:vc1 animated:YES completion:nil];
Also have got this code part but when i use this one tab bar get disappear.
[self.tabBarController setSelectedIndex:yourIndex];
Related
I am navigating from TabBarController to another UIViewController.
aViewController.title = #"Product Name";
[self.tabBarController.navigationController pushViewController:aViewController animated:YES];
after navigating from the tabbar is not visible.
So change code
[self.navigationController pushViewController:aViewController animated:YES];
TabBar is visible but < Back button is not visible.
How to have tabbar and the default back button after navigating from tabbar?
I've just created a test project for this issue and you will see that it's working as expected.
https://github.com/Pei116/TabTest-iOS
I'm learning IOS now, and working on Tab Bar Veiw Controller. I want to hide the tab bar on sub view, so I set 'Hides Bottom Bar On Push' true, it's working fine on second view. But if I set it true on Third View, the Tab Bar is not hidden.
How can I hide the tab bar when third view push?
I already try to find the result on line, but cannot find, please help me.
You can follow code below, hope can help you
DetailViewController *detailViewController = [[DetailViewController alloc] init];
detailViewController.hidesBottomBarWhenPushed = YES;
[[self navigationController] pushViewController:detailViewController animated:YES];
[detailViewController release];
I have structure of project as shown below.
On the left side I have MainViewController. There I have two buttons as English and Arabic. What I want to do is when I click English, I want to go English tab bar controller (HomeViewController).
Hence what I wrote is
- (IBAction)langEnglish:(id)sender {
HomeViewController *secondView = [self.storyboard instantiateViewControllerWithIdentifier:#"enghome"];
[self.navigationController pushViewController:secondView animated:YES];
}
This is working perfectly, but I don't see tab bar.
Tab bar is missing from this.
Any idea what is going wrong?
Basically what I have is view controller as main controller and upon clicking button on this controller, tab view controller should get open...
Go to your main storyboard and select your main view controller. On top select Editor->Embed in->navigation bar.
EDIT: If this does not work push to your tab bar and use this code:
self.tabBarController.selectedIndex = 1;
What I did is as below
- (IBAction)langEnglish:(id)sender {
EngTabViewController *secondView = [self.storyboard instantiateViewControllerWithIdentifier:#"engtab"];
[self.navigationController pushViewController:secondView animated:YES];
}
EngTabViewController is the UITabBarController and I assigned id to tab bar controller... this works like charm...
Means instead of viewcontorller, I used tabbarcontroller...
You shouldn't push a UITabBarController on a UINavigationController. Set it as the window's root view controller instead and the tab bar should be displayed as expected.
I have an application with several view controllers controlled from a tab bar controller. From one of these view controllers I want to (on clicking a button) segue to another view controller and retain the tab bar at the bottom of the segued to view.
I've used
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:#"newView"]){
UIViewController *controller =segue.destinationViewController;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
}
}
This works fine except the tab bar is missing from the segued to view (a placeholder shows for it in the storyboard, but it doesn't show up when the app is run)
I've also tried replacing
[self presentModalViewController:controller animated:YES];
with
[self presentViewController:controller animated:YES completion:nil];
but that doesn't work either.
A bit of debugging shows that for the segued-to view controller, the tabBarController property is set to nil.
Is there anyway to retain the tab bar in the segued-to view controller?
From your explanation, I don't think you want a modal controller. Modal is used to overlay, rendering your tab bar useless. From your storyboard, select your segue and select push, not modal.
Push vs Modal (Note the tab bar):
Im using the new storyboarding features with ios. I have a tab bar which also has a class name called mytabbarcontroller. However I do not have a seperate class for this as in a .h/.m file for this since all its implementation is in different views which is sorted. Now i have a view controller which appears before the tab bar with an activity indicator. Once it stops it has to move to the tab bar controller. However i cant initialise it with mytabbarcontroller since i dont have .h files to import. Currently it goes to a tab bar controller with nothing on it - basically it creates a new tab bar controller. My code is as follow. I also tried initwithnibname and gave the nib name - i.e mytabbarcontroller. However this throws an error.
UITabBarController *controller = (UITabBarController *)[[UITabBarController alloc] init ];
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
because you are declaring a new UITabBarController, try this instead, import and intialize the first view of the tab bar, for example
FirstSceneController.h
import "FirstTabViewController.h"
...
FirstTabViewController *firstTab = [self.storyboard instantiateViewControllerWithIdentifier:#"mytabbarcontroller"];
[firstTab setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentModalViewController:firstTab animated:YES];
....
and also be sure to add a navigation controller and connect it to your first scene.