Skip to content

Commit

Permalink
修改load方法
Browse files Browse the repository at this point in the history
  • Loading branch information
changsanjiang committed Jul 9, 2018
1 parent 7678a2f commit c652dab
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
Binary file modified SJBackGRProject/.DS_Store
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion SJFullscreenPopGesture.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Pod::Spec.new do |s|

s.name = "SJFullscreenPopGesture"
s.version = "1.4.1"
s.version = "1.4.2"
s.summary = "fullscreen pop gestures."
s.description = 'fullscreen pop gesture. System native gestures and custom gestures are free to switch.'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ + (void)load {
SEL swizzledSelector = sel[++ i];
Method originalMethod = class_getInstanceMethod(nav, originalSelector);
Method swizzledMethod = class_getInstanceMethod(nav, swizzledSelector);
method_exchangeImplementations(originalMethod, swizzledMethod);
BOOL added = class_addMethod([self class], originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
if ( added ) {
class_replaceMethod([self class], swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
}
else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion SJNavigationPopGesture.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "SJNavigationPopGesture"
s.version = "1.4.1"
s.version = "1.4.2"
s.summary = "fullscreen pop gestures."

# This description is used to generate tags and improve search results.
Expand Down
12 changes: 9 additions & 3 deletions SJNavigationPopGesture/SJNavigationPopGesture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,15 @@ public class SJNavigationPopGesture {
for sel in selArr {
let originalSelector = sel[0]
let swizzledSelector = sel[1]
let originalMethod = class_getInstanceMethod(cls, originalSelector);
let swizzledMethod = class_getInstanceMethod(cls, swizzledSelector);
method_exchangeImplementations(originalMethod!, swizzledMethod!)
let originalMethod = class_getInstanceMethod(cls, originalSelector)!;
let swizzledMethod = class_getInstanceMethod(cls, swizzledSelector)!;
let added = class_addMethod(cls, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))
if ( added ) {
class_replaceMethod(cls, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
}
else {
method_exchangeImplementations(originalMethod, swizzledMethod)
}
}
}
}
Expand Down

0 comments on commit c652dab

Please sign in to comment.