tags:

views:

17

answers:

1

Hello all,

I am displaying a Customized UIAlertView. I need to know how to get access to the touch events taking place in that AlertView.

I have a controller class which is set as the delegate of my customized UIAlertView, with the following method, but this is not triggered on touching being taking place in AlertView.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
A: 

Another solution (instead of overriding UIVoiw and - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event) could be the usage of UIGestureRecognizer.

UIGestureRecognizers are very powerful and worth a look anyway.

In this case you don't have to deal with inheritance, but can add it to any view.

- (id)initWithFrame:(CGRect)frame {
    if ((self = [super initWithFrame:frame])) {
tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self 
                                                                action:@selector(tapGestureDetected:)];
        [self addGestureRecognizer:tapRecognizer];
    }
    return self;
}

-(void) tapGestureDetected:(UITapGestureRecognizer*)recognizer
{   
    int numberOfTapAreas = [self.delegate numberOfTabAreas];
    CGPoint p= [tapRecognizer locationInView:recognizer.view];
    //...

}
vikingosegundo