Weird problem with UIBarButtonItem in Interface Builder - iphone

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.

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.

UIWindow doesnt allow me to see my UIToolBar

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.

iPhone: Translucent navigation bar inside a UITabBarController

Here it is.
I have a UINavigationController inside a UITabBarController.
Is there a way to set the navigation bar translucent??
I tried, programmatically, to set it like this:
navigationController.navigationBar.translucent = YES;
but nothing changes.
I even tried to log the translucent value and it is actually YES but the bar is still completely opaque.
The view behind the nav bar covers the full screen, i can even see it under the (translucent) status bar. I really don't understand.
All this happens only if the nav controller is inside the tabbar controller.
EDIT:
Guess what? It was xcode screwing up my nib file ...
I recreated the xib from scratch and it works as expected.
Thanks anyway
You are setting the wrong property:
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
I am also trying to change navigation bar style for my UITabBarController based app recently using XCode 4.2.1. The code given by Zebs is wrong in this context. If you are working with navigationController that you create by yourself, then it'd be ok, but the thing is, the navigationController created by the UITabBarController is created by UITabBarController hence the correct code is:
self.moreNavigationController.navigationBar.barStyle = UIBarStyleBlack;
Note we use moreNavigationController instead of just navigationController. Hope that helps everyone who is facing the same problem.

Adding a Navigation Controller to an existing project

I'm sure this is something stupid (it nearly always is when I finally decide to post :) but I can't seem to figure it out, so here goes:
I have a project which contains a UITableViewController (among others) which works fine, but I decided I wanted to enable editing on it and that means it needs to be contained within a UINavigationController. So I added one to the project, set it up so the view is loaded from my table view controller nib, and... it comes up empty. Just a white view with the blue nav controller bar up top.
I've verified that the table view is getting loaded - viewDidLoad runs, at least. Clearly something's not hooked up, probably something in IB, but I just can't seem to see it.
Any suggestions?
In your AppDelegate.h class
UINavigationController *navigationController;
In your AppDelegate.m class
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
(NSDictionary *)launchOptions
{
navigationController = [[UINavigationController alloc]
initWithRootViewController:viewController];
[self.window addSubview:navigationController.view];
}
Try this. It may solve your problem.
Change the class inheritance from UITableViewController to uiviewcontroller. In the xib put the table view and attach it with an iboutlet for uitableview, set the two required protocols for table view and hope that is done if I am not missing anything.
It seems you forget to pass nib name in the interface builder. Try selecting viewControler inside UINavigation Controller in interface builder and set the nib name and class there. If you by-mistake set the nib name and class name on UINavigation controller remove the nib name and class from there.
Its to use the navigation bar rather than using navigation controller since it can fulfill your requirements.
Just place the navigation bar in Xib file & add an action button event over the button.

Persistent UIBarButtonItem in UINavigationBar?

I have an UINavigationController with a UIBarButton to realod something.
However, when I push another view on the Navigation Controller, the BarButtonItem disappears. How can I avoid this?
Do I need to add some code in the NavigationController, or set a property for the BarButtonItem?
Thank you.
Add the button to every view controller. It'll still visibly crossfade between them (oh well).
I'm sure there are plenty of hacks you could do (like adding subviews directly to UINavigationBar) but that's likely to break between OS releases.