0
With CydiaSubstrate
我們可以很容易地鉤住下面的方法,但我想知道如何卸載鉤子並將實現恢復到原始狀態?謝謝!有沒有什麼優雅的方式可以恢復掛鉤的方法在iOS上的原始實施?
static IMP original_UIView_setFrame_;
void replaced_UIView_setFrame_(UIView* self, SEL _cmd, CGRect frame) { // Note the implicit self and _cmd parameters are needed explicitly here.
CGRect originalFrame = self.frame;
NSLog("Changing frame of %p from %@ to %@", self, NSStringFromCGRect(originalFrame), NSStringFromCGRect(frame));
original_UIView_setFrame_(self, _cmd, frame); // Remember to pass self and _cmd.
}
...
MSHookMessageEx([UIView class], @selector(setFrame:), (IMP)replaced_UIView_setFrame_, (IMP *)&original_UIView_setFrame_);
哦,非常感謝你,這真的很簡單明瞭。方式非常意外^^ – Suge 2015-02-11 12:17:05