4

In the app that not optimized for iphone 6 in standard display mode keyboard and status bar shows zoomed. This causes my manually layouted custom keyboard extension to show streched. How can I detect this zooming to fix layout?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
samir105
  • 949
  • 11
  • 16
  • Unfortunately no. Whatsapp updated and now is optimized for iPhone 6, 6+, but there are apps that aren't updated. – samir105 Dec 01 '14 at 18:52
  • 1
    `not iphone 6 optimized app` is apps doesn't support iPhone 6,6+ (like viber, trello ...), right? That's my problem too and I have solution – Tony Dec 05 '14 at 03:59

2 Answers2

3

Use self.view.frame.size.width It returns 320 for zoomed mode & 414 for regular mode on my 6+ (hopefully on 6 also) in - (void)updateViewConstraints

Jeet
  • 1,030
  • 2
  • 10
  • 20
  • This answer used to be correct. However since not sure when it width does not return 320 anymore, it rather returns device width 375 for iPhone6 and 414 for 6 Plus. – Ahmet Akkök Dec 11 '17 at 21:19
0

Eventually you will not need to do this as whatsapp and other apps get updated (I believe whatsapp just did) but how I get around it temporarily is by getting the size of the view where I am drawing my keyboard view.

CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;

The iPhone 6 and 6+ will tell you that your screen width 320 for portrait and 568 landscape like an iPhone 5. You can then use the same drawing you do for the iPhone 5.

When the app is optimized for the iPhone 6 and 6+ you will get their real measurements.

Something I don't get is why people are downvoting my answer when it is the right one. We had to specifically deal with this problem. When the app where your extension runs is not optimized for iPhone 6 the dimensions are the same as the previous iPhone and the app is scaled up to full screen. Just run in an iPhone 6 an old app that was never updated and see it for yourself.

Julio Bailon
  • 3,735
  • 2
  • 33
  • 34
  • Does it work? For iPhone 6+ i always get width 414 even for app not optimised for iPhone 6 and 6+ – Neelesh Nov 29 '14 at 12:07
  • @Neelesh it works but remember, the resolution depends on the app your keyboard extension is running into. Therefore if the app is not optimized you will get a lower resolution and you must readjust your graphics to look good. One of the examples was WHATSAPP but not anymore as they now are optimized. In any case, it is not a bad idea to keep in mind that there are many apps that are not optimized yet. – Julio Bailon Nov 29 '14 at 16:39
  • As i said I get 414 as screen width for apps which are optimised and for apps which are not optimised. – Neelesh Nov 30 '14 at 08:36
  • This doesn't work. It will still return the actual screen size of the device (not the app running). So iPhone 6 will always return a width of 375 regardless of the app being optimized or not. – JustAnotherCoder Nov 30 '14 at 18:16
  • @JustAnotherCoder that is not correct. In the previous version of WhatsApp that was not optimized the iPhone 6 Plus did not return the 375 value. It was returning the smaller resolution. I don't have any application in mind without optimization but if I find one I will let you know. And I am 100% of that because we had to design a new screen for that specific scenario – Julio Bailon Dec 01 '14 at 17:09
  • 1
    This answer used to be correct. However since not sure when it width does not return 320 anymore, it rather returns device width 375 for iPhone6 and 414 for 6 Plus. – Ahmet Akkök Dec 11 '17 at 21:21