1

I'm still confused with these changes in iOS8. I need to know if a user uses an iPhone in portrait mode. If so I want to change one constraint. Otherwise I leave it as set as in the interface builder. So how can I determine the device?

Thx!

jww
  • 97,681
  • 90
  • 411
  • 885
MichiZH
  • 5,587
  • 12
  • 41
  • 81
  • You can define both constraints in interface builder, and iOS will switch between them accordingly. I just answered something very similar, here: http://stackoverflow.com/questions/25962222/alternative-ios-layouts-for-portrait-and-landscape-storyboard/25963436#25963436 – Marcelo Ribeiro Sep 21 '14 at 20:20
  • That seems what I was looking for. Just one question what I don't understand yet: How can I basically take the same screen layout and ONLY change the constraint for the iPhone screens? Right now if I change it, I change it for all devices :-/ – MichiZH Sep 21 '14 at 20:29
  • And I don't know where I can find this checkbox for which layout a view should be installed in my table view controllers :-/ – MichiZH Sep 21 '14 at 20:31
  • You need to install the iPhone specific constraint only in the iPhone specific Screen layouts. Try selecting the different screen layout options in xcode to see what they cover. – Marcelo Ribeiro Sep 21 '14 at 20:32
  • The checkbox for a constraint is in a different place. I am adding an aswer to this question with the place screenshot. – Marcelo Ribeiro Sep 21 '14 at 20:33

2 Answers2

2

Select the constraint you want to define screen layouts for:

enter image description here

Select the screen layouts you need your constraint installed.

enter image description here

Marcelo Ribeiro
  • 1,718
  • 1
  • 13
  • 27
  • Almost got it working thx alot. But If I deselect "Installed" for my one regular constraint in my Compact/Regular size layout then this constraint is also removed in the other layouts and replaced with the special constraint only for the iPhone...what am I doing wrong? – MichiZH Sep 21 '14 at 20:41
  • You need to mark them installed / uninstalled exclusively per screen layout. I.e. constraint1 should be installed in CxR and not installed in RxR, while constraint2 should be installed in RxR but not in CxR – Marcelo Ribeiro Sep 21 '14 at 20:46
0

How about this one: UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation] ?

Razvan
  • 4,122
  • 2
  • 26
  • 44
  • You probably want `[UIApplication -statusBarOrientation]`. (You want the `UIInterfaceOrientation` not the `UIDeviceOrientation`.) – Aaron Brager Sep 21 '14 at 21:08