imageView = [[UIImageView alloc] initWithFrame:CGRectMake(8, 8, 200, 200)];
imageView.image = [UIImage imageNamed:@"d_citypick.png"];
imageView.userInteractionEnabled = YES;
[self.view addSubview:imageView];
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
[self.imageView addGestureRecognizer:tapGesture];
imageView.image = [UIImage imageNamed:@"d_citypick.png"];
imageView.userInteractionEnabled = YES;
[self.view addSubview:imageView];
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
[self.imageView addGestureRecognizer:tapGesture];
[tapGesture release];
开始怎么弄也没成功,原来是 imageView.userInteractionEnabled = YES; 这一句没写。真郁闷。