moqod / ios-scratch-n-see

The project provides en effect when the user swipes the finger over one texture and by swiping reveals the texture underneath it. The effect can be applied for scratch-card action or wiping a misted glass.
421 stars 104 forks source link

UIButton not clickable #17

Open lsantaniello opened 8 years ago

lsantaniello commented 8 years ago

Hi, I need to add a new button on scratchView when the progres is +0.9. When I add the button, it is not clickable. How can I solve the problem?

Thanks

ghost commented 8 years ago

I updated 'MDScratchSampleViewController.h' for testing your problem...

#pragma mark - MDScratchImageViewDelegate

- (void)mdScratchImageView:(MDScratchImageView *)scratchImageView didChangeMaskingProgress:(CGFloat)maskingProgress {
    NSLog(@"%s %p progress == %.2f", __PRETTY_FUNCTION__, scratchImageView, maskingProgress);

    //Button test
    static  BOOL isPresented = NO;
    if(maskingProgress > 0.5 && isPresented == NO){
        isPresented = YES;
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn setImage:[UIImage imageNamed:@"paint01-02blur"] forState:UIControlStateNormal];
        btn.frame = CGRectMake(50, 50, 100, 100);
        [btn addTarget:self action:@selector(btnAction) forControlEvents:UIControlEventTouchUpInside];
        [scratchImageView addSubview:btn];
    }
}

-(void)btnAction{
    NSLog(@"%s", __PRETTY_FUNCTION__);
}

This is works fine. Please, check your button and button superviews user interaction. Check your button target action.