嗨朋友我创建了这种方法的图像选择它正常工作,但我面临着图像上的问题,当我触摸图像我不能看到图像点击或不是我想突出图像时我触摸它我怎么能做到这一点如何在iphone上触摸事件突出显示图像
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];
CGPoint location= [touch locationInView:self.view];
if(CGRectContainsPoint(firstImage.frame, location))
{
// flag like
select=1;
}
else if(CGRectContainsPoint(secImage.frame, location))
{
select=2;
}
[mComment resignFirstResponder];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:self.view];
if(CGRectContainsPoint(firstImage.frame, location)) {
if(select==1) {
var=1;
}}
else if(CGRectContainsPoint(secImage.frame, location)) {
if(select==2) {
vars=1;
}}
select=0;
}
你有两个图像(一个用于正常状态,另一个用于高亮状态)?最好有两个图像。在touchDown中的imageView中设置突出显示的图像,并在touchUp上重新设置普通图像。 – EmptyStack 2011-05-20 07:21:58