2013-08-06 54 views
1

我正試圖實現某種行爲,其中一個對象執行方法時,水龍頭進入對象的邊界,然後當水龍頭離開它的邊界時,另一個。由於這是一個困難的情況下,以言喻,我畫了一幅畫:控制龍頭「穿過」物體的事件嗎?

Touch drag "through"

哪種ControlEvent資料是這樣的,如果它不存在,有沒有得到這個工作的其他公認的方法?

謝謝, 詹姆斯

回答

1

心不是這個,我知道的任何控制事件。你將不得不自己實現這一點。在視圖控制器(上海華到您的按鈕)把下面的方法是這樣的:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {  
    // Touches began, check the position of my touch. Is it outside a button? 
    // note that in a BOOL 
    ... 
} 

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 
    // was my first touch on a button? if not, see if my current touch is inside 
    // the button, note that 
    ... 
} 

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 
    // Touch is ending, is my touch outside the button and did i cross through earlier? 
    // If so, "drag through" event is successful 
    ... 
} 

希望這有助於