Changing the BadgeValue from a UISplitViewController 's detail view - iphone

The main view of my iPad app is a TabBarController. Each Tab contains a UISplitViewController.
The UISplitViewController contains UINavigationControllers.
How do I change the tab's BadgeValue from a ViewController located within a UISplitViewController.
I've tried setting the TabBarItem property of the ViewController but there is no effect.
Strangely the UIViewContoller's NavigationController and SplitViewController property's are null even though the UIViewContoller is in a NavigationController which is in a SplitViewController .
Summary: The Heirarchy looks like this:
tabbar
splitview
navigation
viewcontroller

Found it.
A TabBarController's tabbar is accessed by the direct child, in this case the SplitController.
Because the SplitController doesn't get loaded until the tab is pressed, you have to set the badge when you create the tabbarcontroller (a custom one).
theSplitController.TabBarItem.BadgeValue = items.Count().ToString();

Related

UITabbarViewController: Use StoryboardReferences

To have each tab content in it's own Storyboar I use storyboard references and configure the title and image in my viewcontroller.
I set the image and the title inside the viewDidLoad method in each viewcontroller. This has the problem that the TabbarItem is not displayed until I tab it, beacause the viewcontrollers are lazy loaded an not when the tabbbarController is loaded.
How can I improve this?
I would suggest you to take UINavigationController before your UIViewController's reference and make root view of that UINavigationController. By this way it will give you a tabbar item to configure in UINavigationController in storyboard.

Show UITabBar on UIViewControllers that are not part of the UITabBar?

I have an iOS app written in Swift with UITabBarController with 5 UIViewControllers. Now, I have a bunch of UIViewControllers that are not part of the UITabBarController. I'd like to be able to show that same tabbar but I have no idea how to do that. Any clue?
More details: This is one of the View Controllers that the tabbar has. I use storyboard references and split my view controllers into separate more manageable storyboards.
So, the big picture:
There's no initial ViewController since I use storyboardId to get to the initial Navigation Controller. From there we have a ViewController embedded in the same Navigation controller. In that ViewController, there are 2 Container views - one of the size of the bottom ViewController that contains the "hamburger" button that toggles the other Container View which has an embedded UITableView in. When a specific cell is selected it should go to Profile ViewController that's not even in the same storyboard. The segue is set to be Push. Either way, doesn't show the UITabBar on the Profile ViewController
how you doing?
I don't know if I understood, but you are trying to show tabbar after going to another screen, right? If the answer is 'yes', try to change your segue to show(e.g. push).
-----Edit-----
You can do with two ways:
Presenting Modally -> using Current Context
Use push(e.g.) with a navigation view controller, you can also hide the navigation bar if you go to Navigation controller -> Attributes inspector -> Navigation Controller -> Uncheck Shows Navigation Bar
Hope now it works!
Best regards

Tabbar not showing after a segue?

I don't know what I'm doing wrong, but my UITabBar is not showing after a segue. Basically, the hierarchy goes like:
Tabbar > Navigation Controller > View Controller > Navigation Controller > View Controller
I tried removing the second UINavigationController in order to make that transition, the first (blue) UIViewController has a slide up menu (just a basic UIView with buttons, that's Y offset is off the screen, with basic animation) and when a button is clicked, it leads to the appropriate UIViewController. Once the View controller is presented, you no longer see the UITabBar. Basically, the View Controller tops it. I tried changing the segue from modally presented to push, but it doesn't change it. I don't know what I'm doing wrong.
Here's a screenshot of the UIStoryboard to illustrate that better. PS: The UITabBar is not visible on this UIStoryboard, but it's shown in the simulator. I can guarantee that.
UPDATE: Full screen of the storyboard added
Set your hierarchy like:-- Navigation > Tabbar > Navigation Controller > View Controller
When u try to push view controller from tab u set tabbar as navigation and most important thing is set your root view hierarchy.
set your break point where view controller is present and then in debug area "po(navigation cotroller)" it's may be nil.
I,it will help you.
Heirarchy of viewController:- Navigation1 > ViewController1 > Navigation2 > ViewController2.(By the this is not good way to handle this type of hierarchy)
when I push from ViewController1 to ViewController2 it will be present because of now set Navigation2 means ViewController2 set as root view Controller.
But I want to push ViewController1 to ViewController2 I need to change root view controller as ViewController2.
Now when I need to remove Navigation2 at that time change root as ViewController1.so,as per your question you need to change root view controller.

Storyboard: inferring navigation bar after changing segues

I am developing a navigation-based app with few views. In the Storyboard, I have a Navigation Controller that points to my main ViewController ("center" view of my app) that points to other views with segues.
At first I wanted this segues to be push but it didn't work properly (the buttons were hardly responding), I've switched to modal (as advised here). Now the segue works fine but whenever I use modal segue, the navigation bar in view it points to disappears (I've tried with other configurations - the navbar is being shown on Storyboard but doesn't work on Simulator).
Where am I making mistake?
With a modal presentation your view controller is no longer part of the UINavigation stack. You can drag in a new UINavigationController, display that as a modal view and have your view controller class the root view controller of the navigation controller.
As suggested by JoePasq, "Have your view controller class the root view controller of the navigation controller". Select your view controller which you want to set as Root screen and goto Editor/EmbedIn option and select navigation controller. You will get a navigation-controller embedded with your root view controller. Instead of setting up segues you can change your screens programmatically in your program. In your method for button click event write a similar code as below;
- (IBAction)okPressed:(id)sender {
UIStoryBoard *storyboard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle: nil]; //MainStoryboard is the name of your storyboard
SecondViewController *secondView = [storyboard instantiateViewControllerWithIdentifier:#"sView"];
//sView is the identifier name set by the user, (present inside Attribute Inspector - View Controller)
[self.navigationController pushViewController:secondView animated:YES];
Let me know if this works or there is also another way to do it.

Push UITabViewController from UIViewController is possible?

my app first viewController is UIViewController.
and when user click button firstView disappear and push UITabViewController
is it possible?
i can't find how to push UITabViewController from UIViewController.
UPDATE sorry, I misread TabVC for UITableViewController. Do you mean UITableViewController or UITabBarController? I'll leave my answer below anyways.
In this instance, it's usually best to have a UITabBarController be the root view object. Although it can be done, it's a messier implementation, in my opinion.
I would in fact make the UITabBarController the root and display the UIViewController modally from that UITabBarController on launch.
The user would be presented with the UIViewController and when they clicked the button, dismiss that modal view, revealing the UITabBarController.
Just use a UINavigationController.
Use the navigation controller to push the tableView as the second level in the hierarchy. As a bonus you'll get the back button for 'free' and you don't have to worry about delegates for getting back to the original UIViewController.
you may try this:
self.tabBarController.selectedViewController
= [self.tabBarController.viewControllers objectAtIndex:2];
it should work because selectedViewController property contains view of selected tab.
First of all you have view controller . And make Second view controller which contain tabbarcontroller . Now just push second view controller . And add tabbarcontroller's view as a subview to second view controller .
Hope you gets it ..