2014-03-04 64 views
0

我已經使用集合視圖單元格來顯示多個圖像。然後每個圖像右上角有一個小圖標。我的問題是如何將點按手勢添加到每個單元格圖像右上角的小圖標。Ios- Ipad- UicollectionViewCell-單元格上的圖標 - 如何將點按手勢添加到xcode 5中的圖標?

我的代碼:

UITapGestureRecognizer *tapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(projectSetting:)]; 
_projectSettingIconButton = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"login-settings.png"]]; 
_projectSettingIconButton.frame = CGRectMake(95, 3, 21, 21); 
[_projectSettingIconButton addGestureRecognizer:tapped]; 
[cell addSubview:_projectSettingIconButton]; 
+2

你忘了添加代碼 –

+0

UITapGestureRecognizer * tapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(projectSetting :)]; _projectSettingIconButton = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@「login-settings.png」]]; _projectSettingIconButton.frame = CGRectMake(95,3,21,21); [_projectSettingIconButton addGestureRecognizer:tapped]; [cell addSubview:_projectSettingIconButton]; –

+0

由謝謝你來幫助我(幫助我),..... –

回答

1

試試這個

添加點觸手勢識別器上的圖標:

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];   
[YOURICON addGestureRecognizer:singleTap]; 

然後添加

-(void)handleSingleTap:(id)sender 
{ 
    // do your stuff; 
} 
+1

我試過這一個tooo .... –

+0

是圖標圖像視圖 – Chetan

+0

如果它只有一個圖標,那麼你可以使用一個按鈕與圖像並添加圖標的圖像。如果是這樣,它會更容易 – Chetan

相關問題