Cocoa Touch - Touches In a UIImageView?

From the top of my head, I can think of two ways you can achieve this Either work with a UIButton instead of a UIImageView Set the button's type to "custom" in Interface Builder and choose your image as the background image of the button. Assign an IBAction to the button and make it invisible from your action If - for whatever reason - you have to stick with an UIImageView create a subclass that overrides touchesBegan:inView: Additionally, make sure that you set the image view's userInteractionEnabled property to YES so that your touchesBegan:inView: selector is called whenever the user touches the view. The default value of that property for UIImageView is NO so the last step is important!

Update Here's some sample code to get you started with the button approach in case you need to do this programmatically: UIButton* btn = UIButton buttonWithType:UIButtonTypeCustom; btn setBackgroundImage:img forState:UIControlStateNormal; btn addTarget:self action:@selector(buttonTouched:) forControlEvents:UIControlEventTouchUpInside; self. View addSubview:btn.

From the top of my head, I can think of two ways you can achieve this. Either work with a UIButton instead of a UIImageView. Set the button's type to "custom" in Interface Builder and choose your image as the background image of the button.

Assign an IBAction to the button and make it invisible from your action. If - for whatever reason - you have to stick with an UIImageView, create a subclass that overrides -touchesBegan:inView:. Additionally, make sure that you set the image view's userInteractionEnabled property to YES so that your -touchesBegan:inView: selector is called whenever the user touches the view.

The default value of that property for UIImageView is NO so the last step is important! Update Here's some sample code to get you started with the button approach in case you need to do this programmatically: UIButton* btn = UIButton buttonWithType:UIButtonTypeCustom; btn setBackgroundImage:img forState:UIControlStateNormal; btn addTarget:self action:@selector(buttonTouched:) forControlEvents:UIControlEventTouchUpInside; self. View addSubview:btn.

Since it needs to be done all programically – user377419 Jul 24 '10 at 15:16 Yep, that should work. I think you can do something like what I just edited into my answer. – Benjamin Jul 24 '10 at 18:02.

Either work with a UIButton instead of a UIImageView. Set the button's type to "custom" in Interface Builder and choose your image as the background image of the button. Assign an IBAction to the button and make it invisible from your action.

If - for whatever reason - you have to stick with an UIImageView, create a subclass that overrides -touchesBegan:inView:. Additionally, make sure that you set the image view's userInteractionEnabled property to YES so that your -touchesBegan:inView: selector is called whenever the user touches the view. The default value of that property for UIImageView is NO so the last step is important!

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions