2012-01-12 80 views
0

,我真的不知道爲什麼當我這樣做的目標是沒有得到所謂:UIPinchGestureRecognizer沒有得到所謂的

UIImage * imgSrc = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageSource]]]; 
      UIImageView * imgView = [[[UIImageView alloc] initWithImage:imgSrc] retain]; 

      UIPinchGestureRecognizer * pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(resizeImage:)]; 
      [imgView addGestureRecognizer:pinchGestureRecognizer]; 
      [pinchGestureRecognizer release]; 

- (IBAction)resizeImage:(UIPinchGestureRecognizer *)sender 
{ 
    //not getting here 
} 

調整大小的圖像是沒有得到調用。圖像顯示得很好

+0

手勢識別器初始化並添加到圖像視圖的方法是什麼?何時將'imgView'添加到視圖層次結構中? – 2012-01-12 20:59:39

回答

1

您需要設置imgView.userInteractionEnabled = YES。它默認爲「NO」。

+0

啊!愚蠢的我..謝謝! – adit 2012-01-12 21:08:28