2

For example: I have UIView and I detect long press - so then new UIView appears. It takes whole screen now. I still have finger down on the screen - I can move finger but I can't move up, beacause then my new UIView will disappear. So now I have to detect touches on my new UIView but neither touchesBegan nor touchesMoved is being called. Is there any way to solve this problem?

Code of my new UIView:

#import "Menu.h"

@implementation Menu
{

  //  int x;
  // int y;
  UIGestureRecognizer *longPressGesture;

}



- (id)initWithFrame:(CGRect)frame
{
  NSLog(@"initWithFrame");
self = [super initWithFrame:frame];
if (self) {
    self.backgroundColor = [UIColor orangeColor];
    self.userInteractionEnabled = YES;
    [self setMultipleTouchEnabled:YES];
    [self setIsAccessibilityElement:YES];
   longPressGesture = [[UIGestureRecognizer alloc]
                       initWithTarget:self
                      action:@selector(longPressBegan:)];

   [self addGestureRecognizer:longPressGesture];

  }
return self;
}


-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
   NSLog(@"TOUCHES BEGAN");
}
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
  NSLog(@"TOUCHES MOVED");
}

-(void)longPressBegan:(UIGestureRecognizer *)recognizer
 {
   NSLog(@"LONG PRESS");
 }

And none of these methods (touchesBegan, touchesMoved,longPressBegan) is called.

Jastine
  • 135
  • 2
  • 13
  • Add new UIGestureRecognizer to appeared UIView? – AndrewShmig May 04 '14 at 10:17
  • Tried this. Also doesn't work. I suppose because of finger is still on screen and new UIView doesn't receive action touches down? – Jastine May 04 '14 at 10:24
  • Are you using `UILongPressGestureRecognizer`? – Himanshu Joshi May 04 '14 at 10:27
  • yes, but also tried other recognizers – Jastine May 04 '14 at 10:29
  • @Jastine, what about changing numberOfTouches (fingers used for detecting touches)? Will be great to see some code which shows new UIView, which precesses touches. – AndrewShmig May 04 '14 at 11:19
  • edited my question, so you can see code of new UIView now. – Jastine May 04 '14 at 13:07
  • 1
    Instead of shuffling responders, you can process events at the object that receives it. In this case it would be the view with a long touch recogniser, in general it might be your `UIWindow`. From there you can delegate events or do the other stuff you want. – A-Live May 04 '14 at 14:01

0 Answers0