How can I add multiple action in a single UIButton? Life for example,
[btn addTarget:self action:@selector(method1) forControlEvents:UIControlEventTouchUpInside];
[btn addTarget:self actio开发者_开发问答n:@selector(method2) forControlEvents:UIControlEventTouchDown];
Thanks
The code you have pasted should work:
[btn addTarget:self action:@selector(method1) forControlEvents:UIControlEventTouchUpInside];
[btn addTarget:self action:@selector(method2) forControlEvents:UIControlEventTouchDown];
I do this all the time. Usually for touchDown and touchUp. The fact that method2 isn't getting called is a bug. Do you have an NSLog() at the beginning of method2?
[btn addTarget:self action:@selector(method1and2) forControlEvents:UIControlEventTouchUpInside];
…
- (void)method1and2 {
[self method1];
[self method2];
}
精彩评论