Post

Replies

Boosts

Views

Activity

UIDevice.current.orientation unknown on iPhone 11 Pro
While testing my app I was having trouble with device orientation. Unknown orientation was reported and I could not figure out why. Then I created really simple app for testing import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // UIDevice.current.beginGeneratingDeviceOrientationNotifications() registerEventListeners() } private func registerEventListeners() { NotificationCenter.default.addObserver(self, selector: #selector(deviceOrientationDidChange), name: UIDevice.orientationDidChangeNotification, object: nil) } @objc func deviceOrientationDidChange() { print("deviceOrientationDidChange \(UIDevice.current.orientation.rawValue)") } } On iPhone 11 Pro it initially prints two lines deviceOrientationDidChange 1 deviceOrientationDidChange 0 Where first line indicates portrait orientation and second line is some kind of nonsense. On iPhone 13 Pro it prints correctly only the first line. Some sort of bug in iOS on some (old) devices? In code above the .beginGeneratingDeviceOrientationNotifications() is commented out as it has no effect to anything.
0
0
719
May ’23
Promotional Text now shown
I tried to use App Store Connect to enter Promotional Text for my iOS app. After waiting for some time (actually 48 hours and then more) I did not see the text when checking App Store on my iPhone. Then I thought that as my iPhone was set to use my native language but my app is only in English and I have entered all App Store Connect texts only in English (U.S.) maybe I should try to change my iPhone language to English too. And surprise - I could see the Promotional Text. I got response from Developer Support that they could see my Promotional Text both in English and Spanish language devices, but when changing the App Store to another country, in this case Germany, it did disappear. I don’t know how they changed the App Store to another country. Maybe they changed Region (General / Language & Region) or they have test devices that have some sort of country selection for App Store. Anyway though different procedure the end result was same as my result when changing language.  So my experience is that Promotional Text is not shown for all customers with devices running iOS 11 or later This problem may be affecting only small developer like me as I suspect that big developers have more languages configured on the App Store Connect so that they enter Promotional Text to each language separately. But as a small developer I don’t have resources to translate everything to several languages. And would not be practical to create multiple languages and fill all with English texts just to get Promotional Text shown. Has anyone else encountered this problem?
2
0
1.8k
Feb ’21
SwiftUI for iOS does not close popover
I have a default SwiftUI project for iOS. I want to have different layout for horizontal and portrait modes. Here is my ContentView import SwiftUI struct ContentView: View {     @Environment(\.verticalSizeClass) var vSizeClass     @StateObject private var myState = MyState()     var body: some View {         HStack {             if vSizeClass == .compact {                 MyView()             } else {                 MyView()             }         }.environmentObject(myState)     } } struct MyView: View {     @EnvironmentObject private var myState : MyState     var body: some View {         Button(action: {             myState.isShown = true         }, label: {             Text("Popover")         }).popover(isPresented: $myState.isShown, content: {             PopView()         })     } } struct PopView: View {     @EnvironmentObject private var myState : MyState     var body: some View {         Button(action: {             myState.isShown = false         }, label: {             Text("Close")         })     } } class MyState  : ObservableObject {     @Published var isShown = false } Now I run it by selecting iPhone 13 as emulator and do the following touch button Popover rotate emulator view 90 degrees touch button Close Problem is the popover remains on screen and can’t be closed. Any ideas?
1
0
1.2k
Sep ’21
SwiftUI EnvironmentObject and Alert Failure
I have a default SwiftUI project for iOS. I want to run that on Apple Silicon macOS. Here is my ContentView import SwiftUI struct ContentView: View {     @StateObject var stateObj = StateObj()     @State var showTest = false     var body: some View {         Button(action: {             showTest = true         })         {             Text("Test Button")         }         .sheet(isPresented: $showTest) {             FailingView()         }         .environmentObject(stateObj)     } } struct FailingView: View {     @EnvironmentObject var stateObj: StateObj     @State private var showAlert = false     var body: some View {         VStack(content: {             Toggle(isOn: $stateObj.toggleState) {                 Text("Test")             }         })         .alert(isPresented: $showAlert, content: {             Alert(title: Text("Failure reason"))         })     } } class StateObj: ObservableObject {     @Published var toggleState = false } Now I run it by selecting My Mac (Designed for iPad) and do the following Click Test Button. App fails with Fatal error: No ObservableObject of type StateObj found. After removin alert method the app works as expected. Alert method has some strange side effect that causes the app to fail on Mac. Any ideas?
3
0
898
Sep ’21
SwiftUI DisclosureGroup breaks on macOS
I have a default SwiftUI project for iOS. I want to run that on Apple Silicon macOS. Here is my ContentView import SwiftUI struct ContentView: View { @State private var isOpen1 = true @State private var isOpen2 = false @State private var toggle1 = false @State private var toggle2 = false var body: some View { DisclosureGroup("Test 1", isExpanded: $isOpen1) { Toggle("Toggle 1", isOn: $toggle1) }.padding() DisclosureGroup("Test 2", isExpanded: $isOpen2) { Toggle("Toggle 2", isOn: $toggle2) }.padding() } } Now I run it selecting My Mac (Designed for iPad) and do the following Click Test 1 group to close it Click Test 2 group to open it Click Toggle 2 to change its state Problem is that step 3 does not work. It works on iPhone and iPad but not on Mac. What I see from other experiments this seems to somehow connect to the animation. If I programmatically open and close DisclosureGroups without animation, this seems to work but with animation stops working. Random clicking may fix things until it breaks again. Affects at least Toggle and Slider. Any ideas?
1
0
963
Jun ’21