UIWindow doesnt allow me to see my UIToolBar - iphone

I am in a situation where I'm customizing a existing project.
When trying to create a UIToolBar in Interface Builder it appears.
Once I press Run and Build and the app runs, There is just a blank screen.
Any ideas on how I can get the UIToolbar to appear in the foreground.
Any help is appreciated

Without looking at some code, there are many reasons why it would not show up. My best guess is that you are not actually loading the UIView that you think you are loading. Have you set the Outlets for the UIViewController's view? Are you adding the new view to an existing view with [view addSubview:newView]? IS the Tabbar nested (a child) of the new view in IB or is it on the same level?

You can add code in your AppDelegate to add the UIToolbar subview to your window.
[self.window addSubview:toolbarName];
If customizing the toolbar in IB, you can still do this, just add the toolbar to your AppDelegate as an IBOutlet and connect it in IB.

Related

iOS navigationBar

this is probably quite simple.. but I don't know what's the best practice here.
i have a tabbarcontroller with 4 tabs, 3 of them should be a UINavigationController, the other one should also have the UINavigationBar to it but should not be a nav controller itself.
Now i want to give the UINavigationBar a tint color and an action button. I'd like to do this in the interface builder.
The navBar should always be the same one and i only want to create it once.
But where exactly would i do it? Would i create a .xib file with only the UINavigationBar in it and somehow link to that?
I'm very confused here, most tutorials only discuss the navBar for ONE navController but in my case i need the same bar for different ViewControllers..
NavBar comes with the navigationController or can come seperate. It is a subclass of UIView.
You cannot simply share your navBar with all controllers and the non-navigationController. I mean one instance of a navbar. You cannot even set the navbar for a navigationController. It is only readable.
In my understanding you are trying to make the navbar look the same in every controller, am I right?
So you can for instance subclass a UINavigationController and set it up as you want in the init method and init this subclass to add it to the view.
But what about the non-UINavigationController navBar?
Well, that's easy: Simply add your subclassed navigationController to that tab. You don't have to use it as NavController. You simply can add views to his view as to a standard ViewController.

Add a UIView before UINavigation

I have created a navigation based application.
I need to add a UIView before the navigation with the company details and have user to click on a button to enter the UINavigation view.
How can i do that?
Thanks.
Make the UINavigation's viewdidload show a modal viewcontroller, and give the viewcontroller a button to dismiss it.
You can add that UIView directly to the UIWindow, i.e. [self.window addSubview:self.myView]; and as you done with that UIView(after clicking on button), simply remove it from UIWindow and add UINavigationView to UIWindow.

Weird problem with UIBarButtonItem in Interface Builder

First of all, sorry: I'm pretty sure there's something incredibly stupid I'm doing here, and that I should absolutely go to sleep right now.
The problem is that I added an UIBarButtonItem to a nib and wired it to the right outlet, but after my view has been loaded, the ivar I connected is still nil. Is this supposed to work at all, or it only works when you drag the bar button inside a navigation bar in Interface Builder?
The problem was that the UIBarButtonItem was inside an UIViewController instantiated by a UITabBarController, but I had forgotten to set the "Nib Name" field in the view controller's Attributes.

How to reliably place built-in UINavigationController UIToolbar on top of iPad view

I am trying to use the UINavigationController object's built-in UIToolbar object in my iPad application, but I want it to be displayed on top of the view instead of the bottom, which is where it defaults.
I am also hiding the UINavigationController object's Navigation Bar.
In order to make this work, I had to write the following code:
navigationController.navigationBarHidden = YES;
navigationController.toolbarHidden = NO;
navigationController.toolbar.frame = CGRectMake(0, 0, 768, 44);
This solution works with one exception: when the application Enters Background and Becomes Active again, the Toolbar is always repositioned on the bottom of the view.
I've tried moving the code from viewDidLoad to viewDidAppear:animated, and it still behaves this way.
First, is there any better way to approach this, and if not, how can I stop the Toolbar from being repositioned?
I've also instead decided to use my own UIToolbar object and add it to each view via a custom Base UIViewController class' viewDidLoad. However, this causes the Toolbar to animate when each view is pushed or popped because it is actually part of the view, which just seems "hokey".
Any ideas on possible solutions?
Thanks everyone!
It says in the documentation under UINavigationController's toolbar property that:
Access to this toolbar is provided solely for clients that want to present an action sheet from the toolbar. You should not modify the UIToolbar object directly.
This is sort of hackish, but you could make a UIToolbar yourself and add it directly to the window (i.e. over the navigation controller.)
You can use the category below to modify the UIToolbar class to achieve what you're after.
#implementation UIToolbar (setCenter)
-(void)setCenter:(CGPoint)center
[super setCenter:CGPointMake(384, 22)];
}
#end
The toolbar has limited functionality when used with a UINavigationController. It only provides a convenient way to manage the actionsheet in the toolbar.
From the docs: "Access to this toolbar is provided solely for clients that want to present an action sheet from the toolbar. You should not modify the UIToolbar object directly."
The solution I would use is to create a subclass of UIView with convenience methods to manage your actionsheet and any other custom functionality you need. This custom view can be shared across all views in the UINavigationController and placed where ever you like in the parent view. This will give you ultimate control of your custom top placed toolbar.

Custom iPhone App Tab Bar

Alright, this seems simple enough but I haven't found much documentation or posts regarding this. Basically, I want to have a completely custom tab bar at the bottom of my app. Being new to iPhone dev I thought I could do the following:
Place custom images on bottom of
screen to act as tab buttons.
Create a UIView (lets call it
"ContentView") to fill the rest of
the screen that will display the
appropriate tab's NIB. This
"ContentView" is inside the main
UIView for the NIB.
Hook up image "press" actions to the
controller managing all this.
I'm not sure how I would go about loading the appropriate NIB into the "ContentView" with this method though. From the "Touch Up" action method in the controller can I dynamically load a NIB into that "ContentView" UIView?
Something about this whole thing makes me uneasy.
Is there a better way?
To solve your problem I would create a nib with a UIView and its associated content in it. Connect the nib to a UIViewController. This will be the content of each tab. Create as many of these UIView-UIViewController combination as needed.
When the user touches a tab, create and load the UIViewController from the nib using
– initWithNibName:bundle:
Add the UIView in the nib to the main content view as a subview. Use
– addSubview:
As the user presses other tabs load the other nibs into memory and add their UIView into the main content view as a subview.
If a view is already in memory you can show and hide subviews with the following methods.
– bringSubviewToFront:
– sendSubviewToBack:
I think that would work.
You can solve this by,
either make different views with same tab bar image and custom button(load view on IBAction for button click:toucp up inside) or you can make different views for the same view(so you can hide views and show only one view at a time accordingly).
and you can load view (if you app is view based then add other views on window otherwise for navigation based app you need to pushViewController of navigation controller.
This is a tricky task but you need to handle this.