views:

31

answers:

1

collison but its only working for 1 image

- (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]; 
     }
} 

this will work either for

[self addImageSubViewAtX:160.0 atY:190.0];

OR

[self addImageSubViewAtX:90.0 atY:140.0];

but not together

this is method defined by you

- (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];        
}
A: 

I suggest to make a method receive some parameter because they are not absolutely the same

- (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];

}

and then you call it 2 times : [self addImageSubViewAtX:160.0 atY:190.0] and [self addImageSubViewAtX:90.0 atY:140.0]

vodkhang
thanks but where should i call [self addImageSubViewAtX:160.0 atY:190.0]; [self addImageSubViewAtX:90.0 atY:140.0];i want them in viewdidload()
ram
Yeah, you can call them in viewDidLoad()
vodkhang
perfect now one issue is therei am doing this for collison but its only working for 1 image - (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]; } }
ram
when i click on 1 image popup working but not for other
ram
Can you edit the question to add this in as well. It is a long code and hard for me to see. I don't have XCode here
vodkhang