Setting custom target and action in Interface Builder
I have a custom control that is reused frequently. It is meant to respond to a long press. I'd like to be able to set the target and selector in interface builder. Is there any method for having something lik开发者_如何转开发e-
@property (nonatomic,assign) IBOutlet SEL longPressSelector;
Alternatively is there a way to add custom UIControlEvents that can be set it Interface Builder?
Thanks
I think you can use
-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
to start a NSTimer which will count time for you
and
-(void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
to stop that timer and will get for how much time user tapped a view and then you can do an event according to that time for long press.
Hope, it'll help you.
精彩评论