Skip to content

Instantly share code, notes, and snippets.

@rweichler
Last active July 18, 2016 23:27
Show Gist options
  • Save rweichler/0654d6253de6aecd28fa5ea18094b950 to your computer and use it in GitHub Desktop.
Save rweichler/0654d6253de6aecd28fa5ea18094b950 to your computer and use it in GitHub Desktop.
Reference for people who want to add compatibility for EQE in their tweaks
static void (*orig_layoutSubviews)(id, SEL);
static void hook_layoutSubviews(UIView *self, SEL _cmd)
{
orig_layoutSubviews(self, _cmd);
if(_hookedSection) return;
UIView *controlCenter;
for(controlCenter = self.superview; controlCenter && ![controlCenter isKindOfClass:NSClassFromString(@"SBControlCenterSectionView")]; controlCenter = controlCenter.superview);
if(!controlCenter) return;
_hookedSection = controlCenter;
make_scroll(&_scroll, self.frame);
// this is basically where compatibility may get wonky.
// _scroll is the horizontal UIScrollView for EQE.
// EQE basically takes the SUPERVIEW of MPUSystemMediaControlsView
// and adds it to _scrollView. And then it adds _scrollView
// to the old superview of the superview of MPUSystemMediaControlsView.
if(self.superview.superview != _scroll)
{
self.frame = self.bounds;
[self.superview.superview addSubview:_scroll];
[_scroll addSubview:self.superview];
}
else
{
_scroll.frame = _scroll.frame;
}
}
MSIntialize {
Class ccMediaClass = NSClassFromString(@"_MPUSystemMediaControlsView");
if(!ccMediaClass) ccMediaClass = NSClassFromString(@"MPUSystemMediaControlsView");
MSHookMessageEx(ccMediaClass, @selector(layoutSubviews), (IMP)(hook_layoutSubviews), (IMP *)&orig_layoutSubviews);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment