Fixing What Apple Doesn't
It’s one of those days where Apple’s sloppiness on iOS 7 is driving me nuts. Don’t get me wrong; I have a lot of respect in pulling off something as big as iOS 7 in such a short amount of time. It’s just that I see what’s coming in iOS 7.1 and so many annoyances of iOS 7 still aren’t fixed.
Can’t stand Apple’s missing attention to detail in iOS 7. I’m just going to hack and patch this myself. pic.twitter.com/Nnd176rPlz— Peter Steinberger (@steipete) January 4, 2014
No, I’m not talking about the offset arrow, the background – I already made peace with that. But the offset label just looks like crap. (rdar://15748568) And since it’s still there in iOS 7.1b2, let’s fix that.
First off, we need to figure out how the class is called. We already know that it’s inside the printer controller. A small peak with Reveal is quite helpful:
UIPrinterSearchingView is the culprit. Some more inspection shows that it’s fullscreen and the internal centering code is probably just broken or was somehow hardcoded. Let’s swizzle
layoutSubviews and fix that. When looking up the class via the iOS-Runtime-Headers, it seems quite simple, so our surgical procedure should work out fine:
Let’s run this again:
Ah, much better. pic.twitter.com/8yqoa6lrXU— Peter Steinberger (@steipete) January 4, 2014
Done! Now obviously this is a bit risky – things could look weird if Apple greatly changes this class in iOS 8, so we should test the betas and keep an eye on this. But the code’s written defensively enough that it should not crash. I’m using some internal helpers from PSPDFKit that should be obvious to rewrite – comment on the gist if you need more info.
Best thing: The code just won’t change anything if Apple ever decides to properly fix this.