Hello,
I am trying to use the UITouch and i have followed the tutorial. My file format is a bit different than the one on the tutorial out there. however, I do have a UIImageView image on a view. but when i use the function "touchesBegan" and click on the view, everywhere i click including on the UIImageView image. it only say that i am clicking on the view...
This is how i implemented my UITouch:
- (void)touchesBegan
NSSet *)touches withEvent
UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
NSLog(@"view=%@", [touch view]);
NSLog(@"image=%@", image);
}
and when i touch the image and outside of the image, i only get one result:
view=<MyView: 0x529100>
image=<UIImageView: 0x52a690>
i am not sure is it because my IBOutlet on the image is wrong? please help.
EDIT:
in my header i have:
UIImageView *image;
@property (nonatomic, retain) UIImageView *image;
and in my implementation file i have:
UIImageView *temp = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 70.0, 70.0)];
temp.image = [UIImage imageNamed
"image.jpg"];
self.image = temp;
[temp release]
[self addSubview:image];
EDIT2:
Is there anyway i can manually connect my image to the view instead of making a UIImageView int the Interface Builder and connect it?
I am trying to use the UITouch and i have followed the tutorial. My file format is a bit different than the one on the tutorial out there. however, I do have a UIImageView image on a view. but when i use the function "touchesBegan" and click on the view, everywhere i click including on the UIImageView image. it only say that i am clicking on the view...
This is how i implemented my UITouch:
- (void)touchesBegan
UITouch *touch = [[event allTouches] anyObject];
NSLog(@"view=%@", [touch view]);
NSLog(@"image=%@", image);
}
and when i touch the image and outside of the image, i only get one result:
view=<MyView: 0x529100>
image=<UIImageView: 0x52a690>
i am not sure is it because my IBOutlet on the image is wrong? please help.
EDIT:
in my header i have:
UIImageView *image;
@property (nonatomic, retain) UIImageView *image;
and in my implementation file i have:
UIImageView *temp = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 70.0, 70.0)];
temp.image = [UIImage imageNamed
self.image = temp;
[temp release]
[self addSubview:image];
EDIT2:
Is there anyway i can manually connect my image to the view instead of making a UIImageView int the Interface Builder and connect it?