touches event handler for UIImageView

Posted by madmik3 on Stack Overflow See other posts from Stack Overflow or by madmik3
Published on 2010-03-11T17:58:42Z Indexed on 2010/03/11 18:09 UTC
Read the original article Hit count: 366

Filed under:
|
|

I am just getting stated with iPhone development and can't seem to find the answer I am looking for what I want to do.

It seems like I should be able to programmatically create a UIImageView and then set up an event handler for it's touch functions.

in c# i would have something that looks like

Button b = new Button(); b.Click+= my handler code

right now I have this

    CGRect myImageRect = CGRectMake(0.0f, 0.0f, 141.0f, 151.0f);

UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect];

myImage.userInteractionEnabled = YES; [myImage setImage:[UIImage imageNamed:@"myImage.png"]]; myImage.opaque = YES; // explicitly opaque for performance [self.view addSubview:myImage]; [myImage release];

What do I need to do to override the touch events?

thanks

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uiimageview