iPhone6 (no display zoom mode) UIMenuController tr

2019-02-24 09:17发布

问题:

I have a problem with the UIMenuController on my iPhone 6 when I use the standard display mode and device is in landscape mode. On iPhone 6 Plus the problem is in both modes. Maybe it's depends on screen resolution.

In that case, the UIMenuController will be truncated left and/or right. It seems that the UIMenuController can have maximum bounds as if the phone is in portrait mode.

See UIMenuController truncated (iPhone6 landscape schematic): http://imageshack.com/a/img631/8470/ozlaGe.jpg "iPhone6 landscape"

For me it seems like an iOS8+iPhone 6 bug. The code didn't change for a long time and worked. In zoomed display mode, UIMenuController will be displayed correctly like on all other iPhones/iPads incl. iOS7.

... define UIMenuItems....
[self becomeFirstResponder]; // canBecomeFirstResponder returns YES;
UIMenuController *menu = [UIMenuController sharedMenuController];
[menu setMenuItems:items];

.. define frame...
[menu setTargetRect:frame inView:self];
[menu setMenuVisible:YES animated:YES];

Fixed: see comment from Iliya Barenboim

回答1:

The reason is that you didn't have launch images for iPhone 6 and iPhone 6+.

One other thing that I ran into when adding the launch images, is that there is a bug when doing this with an asset catalog. I added static launch images to my project and manually edited my info.plist as described here: https://stackoverflow.com/a/25960203/378179.



回答2:

It's not a compilation issue. I ran the same code on the iPhone 5 iOS 7.1 simulator in Xcode 6.1, and the problem doesn't appear -- only when you run with the iPhone 6 / iOS 8 simulators (and, of course, on the iPhone 6 device itself). So it's a problem with the iOS 8[.1] runtime.