7

にジェスチャー認識機能を失う私はジェスチャーを使用してイメージを操作するために使用PhotoBoothControllerと呼ばれるクラスを持っています。私はiPhone上で実行するとうまく動作します。しかし、私がiPad上で実行すると、私はUIPopoverControllerの中にPhotoBoothControllerを表示します。画像は正常に表示されますが、ジェスチャが認識されないように見えるため、画像を操作できません。私は、UIPopoverControllerがジェスチャーを制御するようにする方法がわかりません。はUIPopoverController

私はpopovercontrollerを提示し、これビューを設定します。

- (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]; 
} 

が、私はそれを行う可能性があります [canvas becomeFirstResponder]を思ったが、違いを作るためには表示されません。多くは感謝

何かアドバイス、ありがとうございました。

UPDATE:コメントごとにコードを追加すること

- (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]] && ![gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]; 
} 
+0

が行われ、あなたのUIPopoverController – Stavash

+0

@stavashにジェスチャー認識(複数可)を添付するために使用されるコードを追加してください - コードはPhotoBoothControllerクラスです。ありがとう! – Smikey

+0

これは興味深い問題です。 UIPopoverControllerに外部的にジェスチャーを追加するのはどうですか?私はそれがかなりの変更を必要と知っているが、私は今すぐ他の提案がありません... – Stavash

答えて

1

いくつかの推測:

  1. カヴァプロパティが設定されて前にviewDidLoadメソッドが呼び出されているため、これはありますか?この場合、別の方法、たとえばviewDidAppearで現在のポップオーバー後に認識プログラムを追加しようとすることができます。

  2. は、私はまた、キーがUIPopoverControllerはポップオーバーの外、他のビューへの相互作用を可能にすることであってもよいことに同意するものとします。だから私は、あなたが実際にself.viewに認識装置を追加するためPhotoBoothControllerviewDidLoad方法の最後に[canvas becomeFirstResponder];を移動し、ここでself.view becomeFirstResponderを試してみることをお勧め。

3

私は同様のアプリケーションで作業しています。私は簡単にキャンバス上の画像を操作できます。 は、キャンバスのプロパティはYESに設定されているuserInteractionEnabled場合

1)をチェックしてください。
2)ジェスチャをキャンバスではなくImageViewに追加することができます。 (私はあなたが画像をスワイプして回転させたいと思っています)。

関連する問題