vendredi 8 mai 2015

iPhone app on iPad: drawViewHierarchyInRect causes glitch

Running an iPhone app on iPad (iOS 8), using drawViewHierarchyInRect to take a snapshot and do a custom animation between two view controllers. It all runs fine on iPhones but when the app is on iPad (not a universal app, iPhone only) you can see a brief glimpse of a bad snapshot when the animation starts. Basically it seems to take a snapshot of the whole iPad screen, including the black edges, rather than just the simulated iPhone screen. The app also hides the status bar but you can see the status bar in the brief glimpse which means it's probably some kind of bug in iOS as the iPad always shows the status bar for iPhone apps at the top of the screen.

Here's the snapshot code;

UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0.0);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:update];
UIImage *snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Incidentally the flash also occurs when using Airplay to show the app on Apple TV.

Aucun commentaire:

Enregistrer un commentaire