我想打電話給在ImageView的的imageView.On觸摸的的TouchEvent,我希望得到一個Image.I的像素現在用這樣的: -如何通過在imageView上調用touchEvent來獲取UIimageView中圖像的像素?
- (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]];
}
是否有可能,如果是的話,請幫助? 。 提前致謝。
看到'userInteractionEnabled'財產 – beryllium 2012-04-10 11:03:15