1

So I'm trying to figure out the least hacky way of showing a popover in portrait on iPhone 6+, while keeping the modal presentation style on 5s and 6.

Using size classes is not an option apparently, since there's no way to differentiate between 6+ and others in portrait.

I'm also aware that Apple uses size classes to differentiate the layout only in landscape, using autolayout for the portrait.

I can either show popovers all the time or modals all the time, except for the landscape 6+.

What I want is to show popovers on 6+ and modals otherwise. Apart from doing something like detecting 6+, what's the most adaptive way that I can do that?

Thanks!

Community
  • 1
  • 1
Andrew
  • 3,166
  • 21
  • 32

1 Answers1

0
NSString *model = [[UIDevice currentDevice] model]
UIDeviceOrientation *orient = [[UIDevice currentDevice] orientation]

If(model != @"6" || orient != UIDeviceOrientationLandscape )
{
   //show popup
}
Aggressor
  • 13,323
  • 24
  • 103
  • 182
  • That still includes logic that has me looking at whether I'm on a specific device and I'm looking at a more general way to differentiate 6+ from the others, using size classes, if possible. I appreciate your suggestion, I'll probably go with something like that, if nothing else comes up. One note: model is a string and you can't compare it with an integer. – Andrew Dec 05 '14 at 18:01
  • You can in AS3 lol. But what you're asking is a way to determine if a model is >6 without having to check for it. That makes no sense...you have to check the model. What would a more 'general' approach even look like? At most you could abstract all this into a Utils class and have it handle model detection e.g. Utils.versionAbove6 that returns a Bool. But other than that I don't know what you're looking for? The compiler to magically know without you having to code anything?! lol – Aggressor Dec 05 '14 at 18:13
  • Actually something that I might have missed about trait collections. The whole point of them and size classes is to avoid checking if you're running on a specific device. Also, when you edited your answer you're comparing one string to another with the < operator, which has undefined behaviour. – Andrew Dec 05 '14 at 18:16
  • If you're using autolayout, the size classes handle this, but you are still going to have to design the constraints for each size class individually, auto layout just checks that for you. But using auto-layout AND programatic viewclass design can be really problematic, I generally stick to one or the other (I have two storyboards, one which uses auto layout and one which doesnt). If you are checking for the model in code, you need to use the above. If you want to program the behaviour of a pop up I don't think autolayout is going to help you there. – Aggressor Dec 05 '14 at 18:19