views:

108

answers:

1

Hi all,

In my application I need to implement touchBegan for the custom View that has been created . I haved added the following method to my custom view class.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{

}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{

}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{

}

But these methods are not called, when my custom view is dragged or moved ... I have also tried setting

[self setUserInteractionEnabled:YES];
[self becomeFirstResponder]; and override the following method :

-(BOOL)canBecomeFirstResponder
{
    return YES;
}

Apart from this , does anything need to be done ...

Any help would be greatly appreciated ...

Best Regards, Mohammed Sadiq.

A: 

If your custom views are dragging or moving already, it sounds like the touches are getting caught by another object. Probably the viewcontroller...? If you are already detecting the touches elsewhere you can pass them along to your custom UIView when you are done with them, or send some other type of notification.

Kenny Winker