我想在 imageView 上调用 touchEvent。在触摸 imageView 时,我想获取 Image 的像素。我正在使用这个:-
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
[sampleImage setBackgroundColor:[UIColor redColor]];
//CGPoint location = [touch locationInView:self.view];
if ([touch view] == sampleImage)
{
url1 = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Na.wav", [[NSBundle mainBundle] resourcePath]]];
[sampleImage setBackgroundColor:[UIColor colorWithRed:10.0/255.0 green:10.0/255.0 blue:10.0/255.0 alpha:1.0]];
}
NSError *error;
audio = [[AVAudioPlayer alloc] initWithContentsOfURL:url1 error:&error];
audio.numberOfLoops = 0;
[audio play];
[sampleImage setBackgroundColor:[UIColor redColor]];
}
有可能吗?如果是,请帮助。提前致谢。