views:

219

answers:

3

Good morning,

I just got creazy with connecting the "File' Owner" to a Button in my Toolbar. How do I do that?

I only can grab the Toolbar but not the buttons inside. Anyone knows how to solve that :)?

Thanks in advance!

A: 

Make sure File's Owner is set to an actual class (look in the identity inspector). Next make sure that you have an IBOutlet for the button.

@interface Foo { IBOutlet UIButton *button; }

Then ctrl-drag from the File's Owner node to the button (either in the view heirarchy or the actual screen).

If you still can't select the button, then either the types don't match or perhaps the toolbar is just simulated...?

Ben Scheirman
A: 

I'am so stupid. Thanks for your help.

The Button down in the toolbar is not type of UIButton its more type of UIBarButtonItem. Now that works!

Thanks again!

A: 

For a sample iPhone application the process of creating a connection to a UIButton (IBOutlet) so that you can make changes to the UIButton goes like this:

myClass.h

#import <Cocoa/Cocoa.h>

@interface myClass {

    UIButton *myButton;
}

@property (retain) IBOutlet UIButton *myButton;

@end

myClass.m

#import "myClass.h"

@implementation myClass

@synthesize myButton;

@end

Then open your XIB file in Interface Builder and press and hold Control, the drag the mouse from the UIButton in your interface to the File's Owner object in the Document window (Command+0) in IB. Then choose the IBOutlet.

For the Outlet to be seen when you drag normally requires that you build the project before going into Interface Builder, and yes secondly check that you have the class type for the IBOutlet that you created is correct.

Brock Woolf