# Import
<Objc/objc. h>
# Import <objc/runtime. h>
-(Void) sendeventhooked :( uievent *) event {
// Do what you want to do here
Nslog (@ "interception event: % @",
[Eventdescription]);
// Execute the original message passing process
[Selfperformselector: @ selector (sendeventoriginal :) withobject: event];
}
-(Bool) Application :( uiapplication *) Application didfinishlaunchingwitexceptions :( nsdictionary
*) Launchoptions
{
Method sendevent = class_getinstancemethod ([uiwindowclass], @ selector (sendevent :));
Method sendeventmyself = class_getinstancemethod ([selfclass],
@ Selector (sendeventhooked :));
IMP sendevenibd = method_getimplementation (sendevent );
Class_addmethod ([uiwindowclass], @ selector (sendeventoriginal :),
Sendevenibd, method_gettypeencoding (sendevent ));
IMP sendeventmyselfimp = method_getimplementation (sendeventmyself );
Class_replacemethod ([uiwindowclass], @ selector (sendevent :),
Sendeventmyselfimp, method_gettypeencoding (sendevent ));
Self. Window = [[[uiappswalloc] initwithframe: [[uiscreenmainscreen] bounds] autorelease];
// Override point for customization after application launch.
If ([[uidevicecurrentdevice] userinterfaceidiom]
= Uiuserinterfaceidiomphone ){
Self. viewcontroller = [[[viewcontrolleralloc] initwithnibname: @ "viewcontroller_iphone" Bundle: Nil] autorelease];
} Else {
Self. viewcontroller = [[[viewcontrolleralloc] initwithnibname: @ "viewcontroller_ipad" Bundle: Nil] autorelease];
}
Self. Window. rootviewcontroller = self. viewcontroller;
[Self. windowmakekeyandvisible];
Return yes;
}
Then you can create a button elsewhere to capture the button touch event!