I'm developing an app which targets iOS 6.1 and up, iPhones and iPads. It's mostly openGL and uses GLKit. I have a simple color picker to change colors. It's just an square with the color, and three sliders, red, green and blue. I'm overloading viewWillLayoutSubviews to do this: in portrait mode, the square is on top with the sliders below. In landscape mode, the sliders move to the right. Except that I keep getting unexpected behaviors depending on the simulator (I only have an iPhone 5 iOS 8 and it behaves fine).
So I wrote a little debugging code to see what was going on:
- (void)viewWillAppear:(BOOL)animated {
currentOrientation = (UIInterfaceOrientation)[[UIDevice currentDevice]orientation];
if (currentOrientation == UIInterfaceOrientationUnknown) {
currentOrientation = [UIApplication sharedApplication].statusBarOrientation;
}
NSLog(@"Device: %@ OS: %@ Orientation: %@", ([SystemInfo deviceType] == iPad)?@"iPad":@"iPhone",
([SystemInfo operatingSystemIs8OrGreater])?@"8":@"7",
(UIInterfaceOrientationIsPortrait(currentOrientation)?@"portrait":@"landscape"));
NSLog(@"Frame dimensions: width=%d height=%d", (int)self.view.frame.size.width, (int)self.view.frame.size.height);
NSLog(@"Bounds dimensions: width=%d height=%d", (int)self.view.bounds.size.width, (int)self.view.bounds.size.height);
SystemInfo is just a little class to return system info. I ran it on the iPhone 5 and iPad 2 simulators, iOS 7.1 and 8.1, in portrait and landscape. Here's what I got:
iPhone 5 (7.1)
Device: iPhone OS: 7 Orientation: portrait
Frame dimensions: width=320 height=568
Bounds dimensions: width=320 height=568
Device: iPhone OS: 7 Orientation: landscape
Frame dimensions: width=568 height=320
Bounds dimensions: width=568 height=320
iPhone 5 (8.1)
Device: iPhone OS: 8 Orientation: portrait
Frame dimensions: width=320 height=568
Bounds dimensions: width=320 height=568
Device: iPhone OS: 8 Orientation: landscape
Frame dimensions: width=320 height=568
Bounds dimensions: width=320 height=568
iPad 2 (7.1)
Device: iPad OS: 7 Orientation: portrait
Frame dimensions: width=768 height=1024
Bounds dimensions: width=768 height=1024
Device: iPad OS: 7 Orientation: landscape
Frame dimensions: width=1024 height=768
Bounds dimensions: width=1024 height=768
iPad 2 (8.1)
Device: iPad OS: 8 Orientation: portrait
Frame dimensions: width=320 height=568
Bounds dimensions: width=320 height=568
Device: iPad OS: 8 Orientation: landscape
Frame dimensions: width=320 height=568
Bounds dimensions: width=320 height=568
Seems as if iOS 7 helps me out by flipping the frame dimensions to what they should be, except that I'm already flipping them because iOS 8 doesn't. It really doesn't matter, I can adapt. But I have 4 questions:
1) What does iOS 6 do? I'm targeting it and I don't have the simulator anymore.
2) What's with the iPad 2 (8.1) simulator? It's giving the same dimensions as the iPhone 5 (8.1). As a result, my color picker is about 1/4 size. Should I just set the dimensions to 1024x768 landscape 768x1024 portrait?
3) What will iOS 9 do? (Or maybe they'll skip 9 like Microsoft and go straight to iOS X - wow, if I'm confused now, that'll really be something.)
4) What will be the dimensions of the next generation of iPads? Can I count on 1024 and 768? It just occurred to me to run the code against the iPad Retina simulator, and the results were exactly the same as the iPad 2.
Thanks in advance. I know this is a little similar to other questions, but they all seemed very vague to me.