There is a way to set an exclusive touch to all buttons in your application, it can be useful.
#import </usr/include/objc/objc-class.h> static IMP gOringinalWillMoveToSuperview = nil; static id newMoveToSuperviewPlusSettingExclusiveTouch(id self,SEL selector,...) { va_list arg_list; va_start( arg_list,selector); gOringinalWillMoveToSuperview(self,selector,arg_list); [self setExclusiveTouch:YES]; return nil; } -(void)addSettingExclusiveTouchToAllUIViewMethodWillMoveToSuperview { gOringinalWillMoveToSuperview = class_getMethodImplementation([UIButton class], @selector(willMoveToSuperview:)); class_replaceMethod([UIButton class], @selector(willMoveToSuperview:), &newMoveToSuperviewPlusSettingExclusiveTouch, " v@ :"); }
If you do not understand this, you can refer to this and this .
source share