开发者

[xcode-iPhone]two quick touches

开发者 https://www.devze.com 2023-02-23 01:19 出处:网络
Hello, I would like to know how a button that recognizes a touch and two quick touche开发者_运维问答sTry to add following action to Your Button

Hello, I would like to know how a button that recognizes a touch and two quick touche开发者_运维问答s


Try to add following action to Your Button

UIControlEventTouchDownRepeat

Example

    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(100.0, 100.0, 80.0, 50.0);
    [button setTitle:@"Tap Me!" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(touchDownRepeat:) forControlEvents:UIControlEventTouchDownRepeat];     
    [self.view addSubview:button];


This might sound hackish, but you could subclass the UIButton and override the touch events and do you magic if [touch tapCount] == 2.

Don't start throwing stuff! I know it's not elegant.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号