2011-05-29 45 views
2

我使用touchesBegan:withEvent:來獲得用戶在屏幕上的觸摸,但是當我觸摸按鈕時,不會調用此方法。有沒有什麼方法可以確定哪個按鈕被點擊?uibutton touchesBegan

編輯:

-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event 
{ 

    UITouch *touch = [[touches allObjects] objectAtIndex:0]; 
    CGPoint finger = [touch locationInView:self]; 
    int x = finger.x; 
    int y = finger.y; 

} 

這是touchesBegan:withEvent:方法。我給每個UIButton一個標籤號碼。我確實在界面生成器中連接了UIButton。

+0

你是怎麼執行這個操作的?我們需要更多信息。 – 2011-05-29 21:00:59

+0

如果你發佈了一些代碼,它會有所幫助,如果你使用InterfaceBuilder,你是否還記得連接插座? – LuckyLuke 2011-05-29 21:05:05

+0

按鈕消耗觸摸,不要傳遞它。如果您能分辨出您要做的是什麼,我們可以幫助您找到最佳解決方案。 – 2011-05-29 21:32:01

回答

3

請看this的問題。確切地說你需要什麼。

+0

thx,問題是,當我使用它是在UIButton未按下時需要發生的方法 – yosifz8 2011-05-29 21:53:24