Add Selector to UIButton

ipad, iphone, objective-c, uibutton, uiview

Solution

Unless I'm misunderstanding the question, there's no trick to it.

If you define `(IBAction)buttonPressed:(id)sender` in the main view controller, it's inherited by the iPad view controller subclass. Therefore specifying it as a selector belonging to `self` when the iPad view controller sets up its button should work fine.

Problem

I have `ViewController` and then two different `ViewControllers` that extend that main `ViewController`, one for the iPhone and the other for the iPad. The iPad's `ViewController` instantiates a separate extended `UIView` and sets it as its own view. That view has some buttons, which I want to add its selector methods as some methods in the main `ViewController`. How can this be achieved? So here's a way to visualize this: ``` Main ViewController | iPhone ViewController | iPad ViewController | Some UIView Class --> Button must invoke method in Main View Controller ``` EDIT: I do not use interface builder at all.

Original source