Why aren't my touch-handling methods being called for a UIView subclass?
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 w开发者_StackOverflow中文版ithEvent:(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.
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.
精彩评论