Right now I have a UIViewController subclass that is hosting a UIView subclass. This UIView has a UIButton, and I want the touch event to be sent to the UIViewController subclass. Right now I have a getter method in the UIView subclass, so I grab the button and assign it by just using the reference from within the UIViewController subclass.
What's the best approach to achieve this result?
Add the action event to your ViewController
- (IBAction)myButtonPressed:sender;
Now if you're using IB (you should be) just link it up, or if doing this in code then manually create the event link.
[myButton addTarget:self action:@selector(myButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
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.