Question

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

I only can grab the Toolbar but not the buttons inside. How can I solve that?

Was it helpful?

Solution

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.

OTHER TIPS

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...?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top