결국 어디선가 답을 찾았다. 윈도우(UIWindow)의 sendEvent를 오버라이딩 하는 방법으로 처리해보니 아주 잘 되더라. (코드에서 touchListener는 그냥 UIView 형식의 프로퍼티다.)
- (void)sendEvent:(UIEvent *)event {
if (event.type == UIEventTypeTouches && touchListener != nil) {
NSSet *set = [event allTouches];
UITouch *touch = [set anyObject];
if (touch.phase == UITouchPhaseBegan) {
[touchListener touchesBegan:set withEvent:event];
}
// ...
}
[super sendEvent:event];
}
여러 용도로 활용 가능할 듯.ps. super의 sendEvent를 먼저 실행해 버리면 event가 정리되는지 제대로 동작이 안되었던 경험이 있는데... 진실이 뭔지는 모름. :p
ps2. 이 코드를 쓰면 Apple측에서 Ban 할거라는 이야기가 있다. 내가 생각해도 좀 위험할 것 같기도 하다. 이런 코드는 Cydia에 올릴 때나 쓰는게 좋을 듯.
0 comments:
댓글 쓰기