嘿,我试图在用户触摸ImageView时更改图像。在ImageView的有像“heart1.png”所以,当我触摸屏幕上的图像浏览器将变为“heart2.png”的时刻,这是我的代码,帮助深表感谢:在TouchesBegan上更改图像
这看起来像-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:self.view];
if (location.x >= imageView.frame.origin.x && location.x <= imageView.frame.origin.x + imageView.frame.size.height && location.y >= imageView.frame.origin.y && location.y <= imageView.frame.origin.y + imageView.frame.size.height) {
imageView.image = [UIImage imageNamed:@"heart2.png"];
}
}
什么可行?什么不?你的问题是什么? – 2011-04-11 13:24:53
不与Xcode相关。 Xcode只是一个IDE – vikingosegundo 2011-04-11 13:43:53