How do I add an action to a custom view? Similar to how UIButtons have an action I can connect in Inteface Builder. I can’t use a SEL like below because it’s not an object, what do I use?
@property(nonatomic, weak) IBOutlet SEL action;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You want to make your custom object a subclass of UIControl (which is a subclass of UIView). Then you get all the target/action methods… if you are doing this in code the one to explore will be
If you make a custom UIControl object, then you can drag out a custom view in the storyboard and set it’s custom class to your customControl. Then you can drag out IBAction links to your viewController just as if it were a button.
Here is how to make one in code…