Jump to content

How to %hook RootViewController function


Go to solution Solved by KingRalph,

2 posts in this topic

Recommended Posts

Posted (edited)

I'm trying to modify the properties of an instance variable, so I decided to hook the variable inside the init function (because init is called first). Can someone please review my code? I feel like I'm missing something.

%hook RootViewController
 
- (id)init {
// Hook the instance variable for the ad's view 
adsView = MSHookIvar<UIView *>(self, "_bannerViewContainer");
// Hide the ad's UIView
adsView.hidden = YES;
 
return %orig;
}
%end
Updated by KingRalph
  • Solution
Posted (edited)

I re-coded the tweak. Decided to hook the GADViewController class function instead hooking of the instance variable.

Here is the updated code:

#import <substrate.h>
#import <Foundation/Foundation.h>

%hook GADBannerView

- (void)setFrame:(CGRect)frame {
    frame = CGRectMake(0,0,0,0);
    %orig(frame);
}

%end
Updated by KingRalph

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines