Post

Replies

Boosts

Views

Activity

Reply to iOS 14 .onAppear() is called on DISappear instead of appear
Update: I think I found a solution! (At least until the bug itself gets fixed) -> Try to add a second "OnAppear" modifier somewhere below the one you actually want. VStack{ ... } .onAppear(){ print("Works as usual - only fired on appear, even when navigation back to this view as expected") } .onAppear(){ print("Fired directly after onDisappear") } .onDisappear(){ print("Fired on Disappear as expected") } It seems like the second onAppear modifier always gets fired shortly after onDisappear, as reported here. If your add another onAppear modifier somewhere above, it will behaves initially expected! So this may be a workaround until the bug is fixed, maybe it even helps in finding the cause of the problem. If it doesn't work for you, try putting the second onAppear above the one you want, instead of below. In my tests one or the other seemed to work. If this also doesnt work, try placing the second on Appear somewhere else in your view and debug/experient with which gets fired. For me usually one behaves correctly while the other one show the strange behaviour. I guess it may be some parsing error of the swift document or its timing based problems which may be cause by how many States/Bindings you are referencing in the specific block. Update 2: -> above solution doesnt seem to work as I initially thought Further testing seems to point me towards the conclusion, that it's the code inside the onAppear, that leads to the behavior. Adding a second onAppear somewhere with a simple print works as expected, while my onAppear always shows the incorrect behavior regardless of where I place it. So something inside the onAppear, maybe the amount of code, or some specific references cause the problem
Sep ’20
Reply to NFC tag iOS 14 beta 2
I think I found the cause of the problem: @Environment(\.scenePhase) private var scenePhase If you want to detect app scenePhase changes as are available in iOS14, you probably added this line to your main swift file. The moment this line exists NFC stops detecting tags even if the prompt appears and the delegate method gets triggered. My solution was to remove it and instead use for my purpose @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
Oct ’20
Reply to NFC reads once, then no longer works.
I think I found the cause of the problem: @Environment(\.scenePhase) private var scenePhase If you want to detect app scenePhase changes as are available in iOS14, you probably added this line to your main swift file. The moment this line exists NFC stops detecting tags even if the prompt appears and the delegate method gets triggered. My solution was to remove it and instead use for my purpose @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
Oct ’20
Reply to SwiftUI NavigationLink pops out by itself
Same problem here. iOS 14.5 messed up the whole app navigation und now views are immediately popped upon being pushed so the App jumps around and is unusable. I fear this behavior will find its way into the release version as it is also present in the latest release candidate. Update: Found a fix which is really weird but seems to work until the real cause is found: In the pushing view that contains the NavigationLinks, add the following meaningless Navigationlink next to your existing ones. So far it seems the problem only occurs if you have more than one NavigationLink in a view and I am sure its related to the mentioned new behavior of 14.5 Add this to your view containing your existing NavigationLinks: swift NavigationLink(destination: EmptyView()) {     EmptyView() }
Apr ’21