我在我的視圖中有5個標籤,分別標記爲1,2,3,4和5.我已啓用用戶交互對他們,並添加了一個輕擊手勢。返回標籤時它的標記
現在我想要的是獲取被觸摸標籤的標籤。
我做這樣的事情:
tapGesture=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapGestureSelector)];
tapGesture.numberOfTapsRequired = 1.0;
- (void)tapGestureSelector :(id)sender
{
// I need the tag to perform different tasks.
// So that I would like to get the touched label's tag here.
}
如果我不清楚我的問題請提問。
感謝您期待的幫助。
然後tapgesture的用途是什麼?那麼您不需要爲UIlabel添加手勢。 –
是的!實際上,我沒有測試過這個功能,沒有添加手勢到我們的標籤和任何對象,但是測試後的答案是YES,我可以得出結論,使用** tochesBegan **函數我們不需要添加標籤的手勢。 感謝Midhun MP讓我變得清晰。非常感謝。祝你今天愉快。 – iOmi
@MidhunMP ::請將我的回答投票,因爲我已經更新了它。感謝朋友的期待。 – iOmi