Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在UIAlertView中访问触摸事件_Iphone - Fatal编程技术网

Iphone 在UIAlertView中访问触摸事件

Iphone 在UIAlertView中访问触摸事件,iphone,Iphone,我正在显示自定义的UIAlertView。我需要知道如何访问在该AlertView中发生的触摸事件 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 我有一个控制器类,它被设置为自定义UIAlertView的委托,使用以下方法,但在AlertView中进行触摸时不会触发 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 另一种替代覆盖

我正在显示自定义的UIAlertView。我需要知道如何访问在该AlertView中发生的触摸事件

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
我有一个控制器类,它被设置为自定义UIAlertView的委托,使用以下方法,但在AlertView中进行触摸时不会触发

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

另一种替代覆盖UIView和-voidTouchesBegind:NSSet*touchs with event:UIEvent*event的解决方案是使用UIGestureRecognitor

非常强大,值得一看

在这种情况下,您不必处理继承,但可以将其添加到任何视图中

- (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];
    //...
}

抱歉,我得到了答案,TouchesStart需要添加到UIView类,而不是控制器类。想删除此问题,但我似乎无法。因此,请回答您自己的问题,以帮助其他有类似问题的人