2011-05-08 10 views
2

나는 버튼을 눌러에의 UIEvent를 가지고 있고, NSLog이는 반환터치 이벤트에서 정보를 얻으려면 어떻게해야합니까?

<UITouchesEvent: 0x4b> timestamp: 3764.51 touches: {(
    <UITouch: 0x4b1edf0> phase: Began tap count: 1 window: <UIWindow: 0x4b342b0; frame = (0 0; 320 480); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x4b34400>> view: <UIView: 0x4b356c0; frame = (0 20; 320 460); autoresize = W+H; layer = <CALayer: 0x4b33990>> location in window: {121, 377} previous location in window: {121, 377} location in view: {121, 357} previous location in view: {121, 357} 
)} 

어떻게 같은 레이어 프레임이 정보의 일부를 얻을 수 있습니다.

답변

4
UITouch

이벤트와 연관된 모든 접촉이 합격, UIEvent 다음 UITouch 오브젝트는 차례로 해당 프레임 층에 대한 액세스를 제공 windowview 특성 등

참조에 액세스 할 "fntButtonPress"를 UITouch 객체의 집합으로 사용합니다. 당신이해야 할 일은 당신이 그들에게서 목표물을 찾는 것입니다. 이 예에서는 요청할 때 레이어를 터치로 설정하는 방법을 보여줍니다.

[YourButton addTarget:self action:@selector(fntButtonPress:event:) forControlEvents:UIControlEventTouchUpInside]; 

- (void) fntButtonPress:(id)sender event:(id)event { 
    NSSet *touches = [event allTouches]; 
    UITouch *touch = [touches anyObject]; 
    CALayer *touchedLayer = [touch view].layer; 
} 
2

UIEvent 개체의 컬렉션은 UITouch입니다. 버튼을 누르면

관련 문제