0

画像をクリックすると、別のポップオーバーを表示したいのですが、うまくいきません!

私のハンドル Tap メソッドは次のようになります。

-(void)handleTapView:(UITapGestureRecognizer*)recognizer
{
   CGPoint startPoint = [recognizer locationInView:recognizer.view];
   NSLog(@"handle Tap VIEW!!!!!!!!");

   if ([recognizer.view isKindOfClass:[UIImageView class]] ) {
      NSLog(@"Tap Image!!!!!!!!");        
   }
   else if ([self.popover isPopoverVisible]) {
      [self.popover dismissPopoverAnimated:YES];        
   }
   else {
      ShapesListViewController *shapes = (ShapesListViewController*) [self.storyboard instantiateViewControllerWithIdentifier:@"ShapesListViewController"];

      UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:shapes];
      UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:nav];

      shapes.delegate = self;

      self.popover = pop;   

      CGRect popoverRect;
      popoverRect.origin = startPoint;
      popoverRect.size.width = 1;
      popoverRect.size.height =1;

      [pop presentPopoverFromRect:popoverRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
   }   
}

ビューでdidload:

ImageView *imgv = [[ImageView alloc] initWithImage:[UIImage imagNamed:@"delete.png"]];
imgv.center = CGPointMake(250,250);     
[self.view addSubview:imgv];

ImageView *imgv2 = [[ImageView alloc] initWithImage:[UIImage imageNamed:@"gear.png"]];

imgv2.center = CGPointMake(400,400);
[self.view addSubview:imgv2];


//Tap Recognizer
self.singelTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapView:)];
[self.singelTapGestureRecognizer setNumberOfTapsRequired:1];
[self.view addGestureRecognizer:self.singelTapGestureRecognizer];
4

1 に答える 1