Note that there are some explanatory texts on larger screens.

plurals
  1. POLosing Gesture Recognizers in UIPopoverController
    primarykey
    data
    text
    <p>I have a class called PhotoBoothController that I use to manipulate an image using gestures. It works fine when I run it on iPhone. However when I run it on iPad, I display the PhotoBoothController inside a UIPopoverController. The image appears fine, however I can't manipulate it as my gestures don't appear to be recognized. I'm not sure how to make the UIPopoverController take control of the gestures. </p> <p>I present the popovercontroller and configure the view thus:</p> <pre><code>- (void)presentPhotoBoothForPhoto:(UIImage *)photo button:(UIButton *)button { //Create a photoBooth and set its contents PhotoBoothController *photoBoothController = [[PhotoBoothController alloc] init]; photoBoothController.photoImage.image = [button backgroundImageForState:UIControlStateNormal]; //set up all the elements programmatically. photoBoothController.view.backgroundColor = [UIColor whiteColor]; //Add frame (static) UIImage *frame = [[UIImage imageNamed:@"HumptyLine1Frame.png"] adjustForResolution]; UIImageView *frameView = [[UIImageView alloc] initWithImage:frame]; frameView.frame = CGRectMake(50, 50, frame.size.width, frame.size.height); [photoBoothController.view addSubview:frameView]; //Configure image UIImageView *photoView = [[UIImageView alloc] initWithImage:photo]; photoView.frame = CGRectMake(50, 50, photo.size.width, photo.size.height); photoBoothController.photoImage = photoView; //Add canvas UIView *canvas = [[UIView alloc] initWithFrame:frameView.frame]; photoBoothController.canvas = canvas; [canvas addSubview:photoView]; [canvas becomeFirstResponder]; [photoBoothController.view addSubview:canvas]; [photoBoothController.view bringSubviewToFront:frameView]; //resize the popover view shown in the current view to the view's size photoBoothController.contentSizeForViewInPopover = CGSizeMake(frameView.frame.size.width+100, frameView.frame.size.height+400); self.photoBooth = [[UIPopoverController alloc] initWithContentViewController:photoBoothController]; [self.photoBooth presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } </code></pre> <p>I thought <code>[canvas becomeFirstResponder]</code> might do it but it doesn't appear to make a difference. </p> <p>Any advice much appreciate, thank you. </p> <p>UPDATE: adding code as per comment</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; if (!_marque) { _marque = [CAShapeLayer layer]; _marque.fillColor = [[UIColor clearColor] CGColor]; _marque.strokeColor = [[UIColor grayColor] CGColor]; _marque.lineWidth = 1.0f; _marque.lineJoin = kCALineJoinRound; _marque.lineDashPattern = [NSArray arrayWithObjects:[NSNumber numberWithInt:10],[NSNumber numberWithInt:5], nil]; _marque.bounds = CGRectMake(photoImage.frame.origin.x, photoImage.frame.origin.y, 0, 0); _marque.position = CGPointMake(photoImage.frame.origin.x + canvas.frame.origin.x, photoImage.frame.origin.y + canvas.frame.origin.y); } [[self.view layer] addSublayer:_marque]; UIPinchGestureRecognizer *pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(scale:)]; [pinchRecognizer setDelegate:self]; [self.view addGestureRecognizer:pinchRecognizer]; UIRotationGestureRecognizer *rotationRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)]; [rotationRecognizer setDelegate:self]; [self.view addGestureRecognizer:rotationRecognizer]; UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)]; [panRecognizer setMinimumNumberOfTouches:1]; [panRecognizer setMaximumNumberOfTouches:1]; [panRecognizer setDelegate:self]; [canvas addGestureRecognizer:panRecognizer]; UITapGestureRecognizer *tapProfileImageRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)]; [tapProfileImageRecognizer setNumberOfTapsRequired:1]; [tapProfileImageRecognizer setDelegate:self]; [canvas addGestureRecognizer:tapProfileImageRecognizer]; } - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { return ![gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] &amp;&amp; ![gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload