Skip to content

Commit

Permalink
【iOS】Defer system gestures on screen edges
Browse files Browse the repository at this point in the history
  • Loading branch information
skylersaleh committed Aug 8, 2023
1 parent aeada92 commit b644fa6
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/ios_support.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,29 +61,30 @@ + (void)load
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = [self class];
SEL originalSelector = @selector(prefersHomeIndicatorAutoHidden);
SEL swizzledSelector = @selector(swizzledPrefersHomeIndicatorAutoHidden);
SEL originalSelector = @selector(preferredScreenEdgesDeferringSystemGestures);
SEL swizzledSelector = @selector(preferredScreenEdgesDeferringSystemGesturesSwizzled);
Method originalMethod = class_getInstanceMethod(class, originalSelector);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);

const BOOL didAdd = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
if (didAdd)
class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
else
method_exchangeImplementations(originalMethod, swizzledMethod);
method_exchangeImplementations(originalMethod, swizzledMethod);
});
}

- (BOOL)prefersHomeIndicatorAutoHidden
- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures
{
return YES; //Doesn't matter what you return here. In this you could return the actual property value.
return UIRectEdgeAll;
}

- (BOOL)swizzledPrefersHomeIndicatorAutoHidden //This is the actual `prefersHomeIndicatorAutoHidden ` call
- (UIRectEdge)preferredScreenEdgesDeferringSystemGesturesSwizzled
{
return YES;
return UIRectEdgeAll;
}


@end

void se_ios_set_documents_working_directory(){
Expand Down

0 comments on commit b644fa6

Please sign in to comment.