简体   繁体   中英

Will `IBAction`/`IBOutlet` be accessible in the IB when they arent defined on the ViewController?

I am new to Objective-C and iPhone development.

I have a collection class implementing common UI functionality, eg. an EditBox for typing a formula, a label where the result is rendered, and, a button for executing the calculation.

I want to be able to embed this functionality in various projects. I don't want to generate the UI apriorialy, rather, I want to define a class with IBOutlet and IBAction elements, and, to be able to directly link them with whatever UI is implemented by the application (Using the Interface Builder).

Will IBAction / IBOutlet be accessible in the Interface Builder although they were implemented on a class different than the ViewController ? Is this use-case possible with 'Objective-C' ?

Any help will be appreciated.

yes. you can instantiate every class in interface builder and then use that

eg a Calculator class

=> drag a NSObject from the palette/library into the left pane of IB and change its class in the inspector to Calculator :) then you can use that

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