1
votes

I need to know which method is used to identify tap/mouse click.I know
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {}

which are triggerd when cursor moved. But I want to do following things-

I have an image. When i will click it, similar two image will be created.And so on

Can anyone help????Advanced thanx for your reply.

1
The quoted portions of your question aren't coming through properly, so I don't know what you're trying to ask.Brad Larson♦
The title of your question is misleading; this has virtually nothing to do with Objective-C, and all to do with CocoaTouch.Mike Abdullah

1 Answers

0
votes

The tap events are handled not by the touches method callbacks in UIView, but as targets-actions in UIControl. UIControl is a subclass of UIView, and adds abstractions for taps, drags and other common user actions, so that you do not need to implement the logic yourself.

To add a action for the user tapping a control simply do this:

[myControl addTarget:self
              action:@selector(didSelectFoo:) 
           forEvents:UIControlEventTouchUpInside];

This is usable both if you subclass UIControl yourself, or if you use any of the provided controls such as UIButton, UITextField, UILabel, etc.