@DTS Engineer I have studied this for several hours and had a play with this. But I don't see how this solves my problem I am sure I am missing something, but I still end up trying to convert a String to a View.
Post
Replies
Boosts
Views
Activity
@AnnArborMark Thanks that seems to have done the job nicely, I have read and re-read the page you suggested, and I am still unsure what the "id:.self" does, but as it works I will just use it as you have suggested.
Thanks @Claude31, I am not surprised, why would anything do what its documentation says it will?
@BabyJ , you are a genius, you have come to my rescue once again! Thank you.
@BabyJ It is always the simple solutions that work, Thank you.
I was just trying to use a background image and get it to fit when the user rotates the device. But I have been at it for over a week now, and I can't get it to work, it is far too complicated, so I am just going to go with a plain white background. So thank you for all your help.
@BabyJ
That worked thank you so much. But now whenever I try to pick up the value envOrient.myOrient in the ContentView the App Crashes. What am I doing wrong now:
Claude31,
I give up it was just too difficult, I think a plain white background will do nicely.
How would I use this lovely and simple solution to detect an orientation change?
I tried this and I think I nearly understood it. In the XCode preview, it worked perfectly but when I ran it in the "Simulator" (iPhone 11 and iPhone 15) I got the following runtime error:
SwiftUI/EnvironmentObject.swift:90: Fatal error: No ObservableObject of type OrientationInfo found. A View.environmentObject(_:) for OrientationInfo may be missing as an ancestor of this view.
This seems to be referring to the line "Text("Orientation is ...."
an
Thank you Quinn, that was most helpful and solved it for me.
dakkpaw, you are a genius thank you for an excellent answer.
Thank you darkpaw, but I need this to work on an iMac as well as iOS devices, and "UIDevice" is part of "UIKit" which won't work on OSX. I think I need a SwiftUI solution.
Thank you Claude31, I have tried that but it won't work on an iMac. I think I have to have a solution using SwiftUI
Sorry Claude which tutorial?