2011-09-11 403 views

回答

0

當然。你可以把一個UITapGestureRecognizer上一個UIImageView(記得圖像視圖的userInteractionEnabled屬性設置爲YES):

// assumes "myImageView" is your UIImageView that has user interaction enabled 
UITapGestureRecognizer * tap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)] autorelease]; 
[myImageView addGestureRecognizer:tap]; 

在控制器後...

- (void)tap:(UITapGestureRecognizer *)recognizer 
{ 
    // whatever you want 
} 

但是,您可以設置一個UIButton基本上是一個愚蠢的形象。只需將背景圖像設置爲正常狀態,禁用突出顯示和觸摸時的所有調整,並且您應該完全按照您的想法進行調整。

如果我誤解了你的意見,請隨時澄清。

+0

好吧,我剛剛聽說過UITapGestureRecognizer,並從未使用它。你能告訴我一個例子,我如何使用UITapGestureRecognizer的圖片? –

+0

@Espen:編輯例如。 –

+0

感謝您的幫助! :) –

相關問題