Fixing UISearchDisplayController on iOS 7
iOS 7 is great, but it’s still very much a 1.0. I’ve spent a lot of time working around iOS 7-specific bugs in PSPDFKit and will share some of my work here.
This is how UISearchDisplayController looks on iOS 7:
Pretty bad, eh? This is how it should look:
Here’s the code to fix it. It doesn’t use private API (although there is some view hierarchy fighting), and it’s fairly clean. It uses my UIKit legacy detector, so this code won’t do any harm on iOS 5/6:
I imagine one could subclass UISearchDisplayController directly and internally forward the delegate to better package this fix, but I only need it in one place so the UIViewController was a good fit.
Note that this uses some awful things like dispatch_async(dispatch_get_main_queue()
, but it shouldn’t do any harm even if Apple fixes its controller sometime in the future.