科裏森,但其只工作了1個圖像如何在for循環
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint p = [touch locationInView:self.view];
if (CGRectContainsPoint(CGRectMake(myImage1.frame.origin.x, myImage1.frame.origin.y, myImage1.frame.size.width, myImage1.frame.size.height), p))
{
[pieMenu showInView:self.view atPoint:p];
}
}
這將工作與圖像一般碰撞無論是
[self addImageSubViewAtX:160.0 atY:190.0];
OR
[self addImageSubViewAtX:90.0 atY:140.0];
但不一起
這是方法由您定義
- (void)addImageSubViewAtX:(CGFloat)x atY:(CGFloat)y {
CGRect myImageRect1 = CGRectMake(x, y, 30.0f, 30.0f);
myImage1 = [[UIImageView alloc] initWithFrame:myImageRect1];
[myImage1 setImage:[UIImage imageNamed:@"status_finish.gif"]];
[self.view addSubview:myImage1];
}
我認爲你需要這個如果對於這兩個圖像,對嗎?所以,把另一個如果可能解決 if(CGRectContainsPoint(CGRectMake(myImage1.frame.origin.x,myImage1.frame.origin.y,myImage1.frame.size.width,myImage1.frame.size .height),p)) – vodkhang 2010-07-14 04:45:04
我做過但沒有工作:(任何想法 – ram 2010-07-14 06:09:06