For security reasons I want to disable the new iOS 11 drag & drop feature within my whole app. More specifically the drag part.
In iOS 11 it\'s happening by defa
Found a solution. It is to method swizzle the isEnabled method of UIDragInteraction to return NO in the situations your app may need. Note that normally it's not a good idea to method swizzle.
@implementation UIDragInteraction (TextLimitations)
+ (void)load
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = [self class];
SEL originalSelector = @selector(isEnabled);
SEL swizzledSelector = @selector(restrictIsEnabled);
Method originalMethod = class_getInstanceMethod(class, originalSelector);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
BOOL didAddMethod =
class_addMethod(class,
originalSelector,
method_getImplementation(swizzledMethod),
method_getTypeEncoding(swizzledMethod));
if (didAddMethod) {
class_replaceMethod(class,
swizzledSelector,
method_getImplementation(originalMethod),
method_getTypeEncoding(originalMethod));
} else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
});
}
-(BOOL)restrictIsEnabled
{
if (restrictedCondition)
{
return NO;
}
return [self restrictIsEnabled];
}