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.
Related
I have a UIView (with identifierSplashScreen) which basically acts as a introduction view and displays a small animation. once the animation is completed i want the view to display a tabbar view which here in after will be the main view. no data of any kind is passed on from the first UIView to the second UIView(with identifier HomeScreen). I have seen most examples where the
secondViewController *svc = [self.storyboard instantiateViewControllerWithIdentifier:#"HomeScreen"];
[self.navigationController pushViewController:svc animated:YES];
but this Pushes the view controller and a navigation bar with a back button appears which I dont want. Also I am never going to Return to the Splash Screen. it would be great if one of you could offer any help.
Iam a biggener and not a expert iOS programeer, so a simple code example will be of great help.
Instead of pushing onto the navigation stack why not replace the stack?
eg.
[self.navigationController setViewControllers:#[svc] animated:NO]
You can do a push segue and not have a navigation bar... Select your navigation controller and on the 4th tab on the right uncheck "Show Navigation Bar"
I am trying to create a custom sidebar navigation pane in my iPad app something like Instapaper for iPad. With the help of some excellent tutorials like the one by Scott Sherwood, I was able to create a custom sidebar and switch between the view controllers.
I implemented this using a root view controller in which I have two views - one is the tabbar view, other represents the content associated with the tab selected, something like this...
Whenever I select the tab I just add a subview to the Root View Controller, like this...
#implementation RootViewController
//
// some code here
//
#define TABBAR_WIDTH 80.0F
- (void)buttonTapped:(UIButton *)aButton
{
UIViewController *newVC = [self.storyboard instantiateViewControllerWithIdentifier:#"SomeView"];
[newVC.view setFrame:CGRectMake(TABBAR_WIDTH, 0, self.view.bounds.size.width - TABBAR_WIDTH, self.view.bounds.size.height)];
[self addSubView:newVC.view];
}
Now what I want to do is push a new view into the Contents not based on tab selection but based on some interaction in the contents view. The way I have figured out to do this is adding another subview to the superview. In that case, however I will have to implement the pushing, popping, back buttons, animations between views all by myself.
I was wondering if I can implement this scenario using UINavigationController (so that the pushing, popping, back buttons are handled auto-magically).
Can somebody shed some light over this topic? May be even a brief overview of how this could have been implemented in Instapaper iPad app would help.
Here you require navigation in the container view.
So you can go with this thing:
Have one navigationController (alloc-init-set frame-navigation bar hidden, etc.) having your content1 view controller as root controller.
In Content1 view controller, on button tap event, just push your navigation controller to Content2 view controller, and do the same for pop event
Alloc - init your navigation controller in your root controller where you have your custom tab and container view in xib...
Note: Clear your container view before adding any other views.
I have already done this scenario so its working fine for me.
Hope this is what you required...
Enjoy Coding :)
Im writing an application which the main view controller is a UIViewController. It has some icons in a grid and I want to dismiss (sliding down) this grid when one of the icons is clicked. This I've done already. The problem is: when the grid is dismisseed I want another View to come from the top of the screen. This view is in this same root view controller. But I want to display the content of other view controllers in this view. For example: I want this view to show a UINavigationController with a UITableView inside it, so the user can navigate through TableViews.
I'm doing this:
HorariosViewController *horarios = [[HorariosViewController alloc] init];
[vuashView addSubview:horarios.view];
HorariosViewController is a UINavigationViewController. It shows me only a blue NavigationBar and changes like self.navigationItem.title = #"Title" won't work.
Thanks!
You can show another view controller's views as subviews but their outlets and actions remain linked to their original view controller unless you write code to make new connections, so self.whatever shouldn't be expected to affect the other view controller's properties.
(Also, if HorariosViewController is a UINavigationController, it shouldn't be created as a UIViewController.)
One approach is to have the navigation controller already there, with the icon grid presented modally on top of it. (you can set the view up this way without animations, so the user doesn't see the navigation controller underneath).
Then, when it's time for the grid to go away, it can call dismissModalViewController on itself with animation.
I want to hide tabbarcontroller on one view.
But doing so it is displaying white space and not allowing to put any image or anything else on that place.
So what should I do ?
Put one imageView with your desired image on the view controller where you do not want to show tabBar and hide tabBarController before pushing that view on navigation stack using code like
[viewControllerInstanceWhichIsGoingToPushed hidesBottomBarWhenPushed];
The method is something like this. Then Tab Bar will hide and your imageView with image will be displayed in place of TabBar.
If you add a subview to a hidden view, the subview will also go hidden.
In your case, you can have another view controller with just the activity indicator and display the view controller while the loading operation is done. And, after the loading is over, remove that view controller and show the tab bar controller. An example,
// while loading the content
appDelegate.window.rootViewController = loadingViewController;
// once the loading is over
appDelegate.window.rootViewController = tabbarController;
I have encountered this problem before as well and was not able to get anything to get into the blank space using the normal hierarchy. I got around this problem by adding another level of navigation.
ex:
right now you have at UITabBarController which contains your UIViewControllers.
Instead:
Have another UIViewController as the root and then add the tabbarcontroller onto it either as a modalviewcontroller or as a pushed viewcontroller (if you make your root a navigationcontroller). Then, your rootviewcontroller can freely put views under or over the tabbarcontroller's view, independent of whether the bar is present or not.
I am having a bit of trouble with my navigationController in my app. I am using the Kal Calendar component - https://github.com/klazuka/Kal.
I have created the view controller and have go it to appear in the correct position within in my app i.e. Click on a new tab and init the rootviewcontroller as the KalViewController and it sort of loads correctly but the back button is visible on the navBar when it should be the rootView and it is clickable 5 times before going to the true root, it's hard to explain but I have no idea what is wrong.
i have tried it with a table view and clicking on the first element in the tableView takes you to the calendar which works perfectly but this is not what I want/need in the app.
Thanks.
It sounds like you have both a UINavigationController and a UITabBarController. Make sure that the tab bar controller is your “main” view and that there are separate UINavigationControllers for each view controller in the tab bar. The different tabs’ view controllers should not be in the same navigation controller’s view heirarchy.