Post

Replies

Boosts

Views

Activity

Reply to Updating Time - SwiftUI
Here is something I ripped up and works. I deliberately reduced the timer interval to 0.1 to give a more accurate seconds update. You can download the code in https://github.com/richardlamo/SwitfUI-Clock          let clockTimer = Timer.publish(every: 0.1, on: .main, in: .common).autoconnect()     let calendar = Calendar.current     @State var currentDate = Date()     @State var hour : NSInteger = 0     @State var minute : NSInteger = 0     @State var second : NSInteger = 0          let cyclePeriod = 0.5          var body: some View {         ZStack {             VStack {                 Text("\(hour):\(minute):\(second)")                       }         }         .onReceive(clockTimer) {             time in             currentDate = time             hour = calendar.component(.hour, from: currentDate)             minute = calendar.component(.minute, from: currentDate)             second = calendar.component(.second, from: currentDate)         }     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’22
Reply to Updating Time - SwiftUI
Here is something I ripped up and works. I deliberately reduced the timer interval to 0.1 to give a more accurate seconds update. You can download the code in https://github.com/richardlamo/SwitfUI-Clock          let clockTimer = Timer.publish(every: 0.1, on: .main, in: .common).autoconnect()     let calendar = Calendar.current     @State var currentDate = Date()     @State var hour : NSInteger = 0     @State var minute : NSInteger = 0     @State var second : NSInteger = 0          let cyclePeriod = 0.5          var body: some View {         ZStack {             VStack {                 Text("\(hour):\(minute):\(second)")                       }         }         .onReceive(clockTimer) {             time in             currentDate = time             hour = calendar.component(.hour, from: currentDate)             minute = calendar.component(.minute, from: currentDate)             second = calendar.component(.second, from: currentDate)         }     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’22
Reply to SwiftUI. Navigation toolbar not working after dismissing modal
Sorry, I get the same problem with macOS11 and Xcode 12 with your code. Sounds like something they just fixed in Xcode 13. I don't want to upgrade to macOS12 beta yet.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to SwiftUI. Navigation toolbar not working after dismissing modal
I'm still using Xcode 12 and macOS 11.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to SwiftUI. Navigation toolbar not working after dismissing modal
Nope. I replaced it with Text("Hi"). Same problem.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’21