0

以下のようにCydiaSubstrateメソッドを簡単にフックできますが、フックをアンインストールして元の実装に戻す方法を知りたいですか? ありがとうございました!

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_);
4

1 に答える 1

1

実装を再度交換する必要があるだけです。つまり、次をもう一度呼び出すだけです。

MSHookMessageEx([UIView class], @selector(setFrame:), (IMP)replaced_UIView_setFrame_, (IMP *)&original_UIView_setFrame_);

実装を交換すると、それらが交換されます。したがって、それらを再度交換すると、元の状態に戻ります。

于 2015-02-11T12:04:55.530 に答える