Skip to content

Tweak.xm

J.K. Hayslip edited this page Nov 30, 2019 · 1 revision

Tweak.xm

The fun part the actual code of the tweak.

tvOS processes hook very similar to iOS processes do. So if you coded an iOS tweak this should be a cinch.

Here's a screenshot I will explain it as much as possible. Screenshot

So I import the header file I need this will let the tweak know what the type of subclass the class I'm hooking is.

%hook HBUIMainAppDockGridView I hook this class because this is the dock view on tvOS.

I then look for a method to modify in this case it's the method -(void)layoutSubviews.

Since I have a preference panel for the user to toggle the tweak on and off I check to see if it's enabled or not. (if (kEnabled)) if the tweak is enabled then I modify the dock to hide it.

You want to make sure you call the original method so I then use the logos operator %orig to call the original value, We do this that way we don't cause issues when our tweak is running. I then call [self removeFromSuperview]; since the class I'm hooking is a subclass of UICollectionReusableView and that view is a subclass of UIView that has a method called removeFromSuperView which removes the view in this case the dock view. We use self because we want to modify that class.

If the tweak isn't enabled it will default back to the way it was before it was enabled.

Then we have a method called loadPrefs() which is a void statement we want to make sure the preference changes are loaded after a respring so we call this method in the %ctor method (constructor) that way tweak knows that it's been updated.

Clone this wiki locally