@Sean Allen, you might want to mention that the iPhone considers upside down portrait to be NOT Portrait (in your code, "I'm Landscape"). It would be good to do a follow on to show us how to either lock it into one orientation or deal with the upside down case as well. Love your style.
What I really, REALLY love bout your teaching style, is that you show WHERE the information comes from in the docs and how to use them. I’ve written over a dozen apps in the App Store but I always struggle reading the Apple developer documentation. I can’t begin too say how grateful I am for this teaching style. ❤ Would you explore how to tell the difference between pro max vs regular iPhone though?
Thanks for the kind words, Zoe 😀. When using size classes alone, there's no way to tell the difference (unless the phone is in landscape). There's a way to determine which device specifically, but it's pretty involved and you have to update it every year as new devices come out. But you can read about that here - stackoverflow.com/questions/26028918/how-to-determine-the-current-iphone-device-model
Hi again Sean, may I just ask one more question? Is this the CORRECT way to do this for iOS 16+? I ask because I've just had a WWDC 23 SwiftUI Tech lab and they said I must NOT use conditionals, size classes and 'UIScreen.main.trait...' stuff in my Views because I'm breaking 'IMPLICIT IDENTITY' So is this method in your video the new 'correct' way to do all this? Thanks so much, in advance.
@Environment variables work like @State. So when the @Environment var changes, it triggers a UI update. isLandscape is a computed property, so it gets computed each time we use it (which happens when the UI redraws)
I might be missing something but im on an IPad and when I present a hostingController as modalPresentationStyle set to .formSheet with hostingController.preferredContentSize = Some cgsize. The containing swift UI view always gets the horizontalSizeClass as .compact. Any idea?
I loved the video and explanations. I wish to ask a question: how can I rearrange my interface elements depending on orientation (landscape or portrait)? Where can I find some code about this? Thank you very much.
Thanks for your concise video! To advance on that topic: how would you go about differentiating between iPad in Portrait and Landscape since they're both regular/regular size classes? In my case I have a quadratic content view element that should fill the whole height pushed to the left in landscape and the whole width pushed to the bottom in portrait while filling the empty area with designated illustrations. What I'm doing right now is using a Geometry Reader on the full window and combining that information with the size classes, but maybe you know an easier way, prefferably without the Geometry Reader ...
Why does the iPad only have regular when landscape space is much larger and alters the layout!? What were apple thinking?! Surely there should be compact, regular and large?!
Good to see you back in "Teaching Mode" once again ..🙂 Thanks for the video..
Good to be back. More to come!
Thanks for some great ideas on how to improve an app by reacting to the layout and having separate views for both orientations. Thanks Sean!
Happy to help, Brad!
Demystified the whole SizeClasses topic, Thanks Sean!
Glad it helped, Siva
@Sean Allen, you might want to mention that the iPhone considers upside down portrait to be NOT Portrait (in your code, "I'm Landscape"). It would be good to do a follow on to show us how to either lock it into one orientation or deal with the upside down case as well. Love your style.
Thanks! Like your teaching style ))
Looks so simple but important.
Glad you enjoyed it, Maxim!
that's it?! THANKS A LOT FOR MAKING MY LEARNING JOURNY A LOT EASIER!!
Yup. Of course, building the proper UI can be tricky if it's complex. But detecting size classes is relatively simple.
@@seanallen i understand building the proper UI can be tricky, but still!! Super easy and encourages me to keep going 💪🏼
Happy to help!
Thanks man you doing it really good and easy to understand for a newbe =)
Glad to help!
What I really, REALLY love bout your teaching style, is that you show WHERE the information comes from in the docs and how to use them. I’ve written over a dozen apps in the App Store but I always struggle reading the Apple developer documentation. I can’t begin too say how grateful I am for this teaching style. ❤ Would you explore how to tell the difference between pro max vs regular iPhone though?
Thanks for the kind words, Zoe 😀. When using size classes alone, there's no way to tell the difference (unless the phone is in landscape). There's a way to determine which device specifically, but it's pretty involved and you have to update it every year as new devices come out. But you can read about that here - stackoverflow.com/questions/26028918/how-to-determine-the-current-iphone-device-model
@@seanallen Thank you so much! You're a wonderful member of the Dev Community.
I was waiting for it long, thank you lots.
Hope you enjoyed it!
Thank you Sean
Happy to help, Christian.
This was really helpful, thanks Sean!
Glad it was helpful, Anup 😀
I had to do 4 apps but worked thanks dude!
Happy to hear it helped, Bertha!
Very visual and to the point. Thank you Sean 💯
Glad you enjoyed the video style, Joe 👍
Great Video as always Sean!
Thanks William 😀
Great video, Sean. Keep it up the good work. 👍
Thanks 👍
Great video as usual!
Thanks for the support, Maegan!
Hi again Sean, may I just ask one more question? Is this the CORRECT way to do this for iOS 16+? I ask because I've just had a WWDC 23 SwiftUI Tech lab and they said I must NOT use conditionals, size classes and 'UIScreen.main.trait...' stuff in my Views because I'm breaking 'IMPLICIT IDENTITY' So is this method in your video the new 'correct' way to do all this? Thanks so much, in advance.
How does the isLandscape variable change? I thought that a variable had to be @State if it changes in the view.
@Environment variables work like @State. So when the @Environment var changes, it triggers a UI update. isLandscape is a computed property, so it gets computed each time we use it (which happens when the UI redraws)
I might be missing something but im on an IPad and when I present a hostingController as modalPresentationStyle set to .formSheet with hostingController.preferredContentSize = Some cgsize. The containing swift UI view always gets the horizontalSizeClass as .compact. Any idea?
I loved the video and explanations. I wish to ask a question: how can I rearrange my interface elements depending on orientation (landscape or portrait)? Where can I find some code about this? Thank you very much.
Great tuts
Thanks Rahul!
Nice!
Wow! Thanks a lot! You're awesome :) New like & sub
Thanks for your concise video! To advance on that topic: how would you go about differentiating between iPad in Portrait and Landscape since they're both regular/regular size classes? In my case I have a quadratic content view element that should fill the whole height pushed to the left in landscape and the whole width pushed to the bottom in portrait while filling the empty area with designated illustrations. What I'm doing right now is using a Geometry Reader on the full window and combining that information with the size classes, but maybe you know an easier way, prefferably without the Geometry Reader ...
Why does the iPad only have regular when landscape space is much larger and alters the layout!? What were apple thinking?! Surely there should be compact, regular and large?!