在viewDidLoad中:
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hanldeTap:)];
[self.view addGestureRecognizer:tap];
处理点击事件的方法
- (void)hanldeTap:(UITapGestureRecognizer *)gr
{
NSUInteger index = 1;
index++;
NSLog(@"%d", index);
}
为何我点击后index都不递增呢?NSLog出来的值都是2,肯定是我没有将方法调用对
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hanldeTap:)];
[self.view addGestureRecognizer:tap];
处理点击事件的方法
- (void)hanldeTap:(UITapGestureRecognizer *)gr
{
NSUInteger index = 1;
index++;
NSLog(@"%d", index);
}
为何我点击后index都不递增呢?NSLog出来的值都是2,肯定是我没有将方法调用对