Questions tagged [onappear]

42 questions
1
vote
0 answers

SwiftUI: What is an alternative to using onAppear?

I want to load health data so that when the tab is tapped a users steps are displayed once. But by using onAppear, every time the tab is tapped it loads the steps again and displays them twice. I believe this is due to the onAppear. What alternative…
Mxyb
  • 83
  • 1
  • 9
1
vote
2 answers

SwiftUI - Get data in remote JSON data to refresh on App startup

I am a noob (and my code/model currently will show it so please go easy on me!). I’m taking a first whack at creating a recipes style (cenotes) app. So that I can update the data I have a remote json file, so users won't have to reinstall to get the…
1
vote
0 answers

In SwiftUI, entering a text field in TabView calls all its views' onAppear()

I have a TabView like so: TabView { View1().tabItem{Text("1")} View2().tabItem{Text("2")} View3().tabItem{Text("3")} } Whenever I enter a TextField in any of the views, onAppear() gets called on all of the views causing bugs and other…
Fred
  • 381
  • 5
  • 17
1
vote
2 answers

Onappearing not working when modal page is popped in Xamarin iOS

I have an onappearing method which doesn’t fire when page is popped in Xamarin iOS but works fine in Xamarin Android. Could anyone please help me with this. Thank you. Page 1 (Tabbed Page) protected override void OnAppearing() { …
Sawan
  • 91
  • 1
  • 9
1
vote
1 answer

Why i don't see my animation when user is logged in?

I created a custom LaunchSreen which works well when the user is not logged in but if he is logged in we do not see the animation (the view goes right to the Home view and doesn't wait for the animation to be completed). Do you have any idea…
Flincorp
  • 751
  • 9
  • 22
1
vote
0 answers

iOS 14 SwiftUI Selecting Textfield Calls Parent View's .onAppear

I call to hide and show my TabBar in my view's .onAppear, this functionality worked fine in iOS 13 and Xcode 11. However, after updating to Xcode 12 and iOS 14 whenever I select a TextField in a child view which was presented via NavigationLink, the…
Jack
  • 304
  • 6
  • 19
0
votes
1 answer

loop animation Image scale & opacity SwiftUI

I have button, with 3 states. none, recording and result. When I start recording, I want to show animation in loop, but when I change it to result state or none state - I should stop animation. reason why I didn't implemented with ternary operator…
0
votes
0 answers

On appear is called before the view appears

I am trying to make an infinite scroll calling the different pages of an api, my problem is that the function onAppear is called before the view is displayed, then it is called to reload when the screen opens and not when you scroll to the bottom, I…
0
votes
1 answer

SwiftUI | Strange behaviour after appending paths to Routerpath onAppear

I want to completely rework how NavigationBar's look and rework back button as I like and have my own router In my app. I created this sample project to understand how NavigationStack and NavigationPath works before starting my project (From this…
0
votes
1 answer

Cannot convert value type '()' to expected argument type '(() -> Void)?' error SwiftUI

I am trying to get the height of an item im creating by setting a geometry reader, then adding an .opAppear on an empty ZStack which pulls the height of the geo reader. struct MyView: View { @State private var height: CGFloat = 0 var body:…
0
votes
0 answers

List with editmode and onAppear

I am trying to display the list of items in editmode after the api call but List does not enter editmode. As a result, regular list of items is shown (not able to select an item). When I have static values, everything works well. The view: struct…
ilito
  • 89
  • 7
0
votes
0 answers

Modifying List Cell only when it appears on screen and pause when it is not on screen in swiftUI

Can we modify List Cell only when it appears on screen and pause when it is not on screen in SwiftUI? struct MyListView: View { @State private var items: [Int] = (0..<30).map { _ in 0 } @State private var timer: Timer? var body: some…
0
votes
1 answer

I don't understand the order that code executes when calling onAppear

I have been getting this problem now a few times when I'm coding and I think I just don't understand the way SwiftUI execute the order of the code. I have a method in my context model that gets data from Firebase that I call in .onAppear. But the…
FreddanF1
  • 11
  • 3
0
votes
1 answer

SwiftUI: Animate multiple views with onAppear dynamically

I want to animate multiple custom shapes and have run into the issue that I can't make subsequent shapes animate immediately after they appear for the first time. My goal is that you can keep replacing the second shape with another shape and it…
b.joe
  • 69
  • 4
0
votes
1 answer

OnAppear only once the view is opened

I want to update the view with data when a view is opened so I added: .onAppear { loadData() } But I only want to update it once when the view gets opened not every time it gets reopened e.g. with a back button. --> Only update on App start