简体   繁体   中英

get IBOutlets from xib file

In my nib file I have several controls that I placed with xcode. Is there a way I can find how many outlets there are in the nib file. since I placed all the objects in the default view of the nib file maybe I can get the child of the default view and those will be the IBOutlets. I plan on latter adding functionality to those IBOUtlets.

In short I am trying to create a connection with code.... Thats cause I have so many objects in every nib file. I am creating an app that is like a power point presentation and I have several slides..

IBOutlets arent' actually anything. That is just syntactical sugar to allow Interface Builder introspection into your code files to match up variable names.

Anyways, you can just look through all the subviews of your view in code if you need to. Not ideal, but i think this is what you are asking for.

SubclassedViewController *controller = [[SubclassedViewController alloc] 
    initWithNibName:@"SubclassedViewController" bundle:nil];

// actually, [[... alloc] init]; does the same

for (UIView *aView in [controller.view subviews]) {
    // do stuff
}

You could identify the Views with tag s, an integer properties that you can attach to any UIView (also in Interface Builder).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM