Post

Replies

Boosts

Views

Activity

Reply to Picker Label not showing anymore
If you embed the Picker inside of a Menu, it lets you create a custom label. I'm not sure if this was intended by SwiftUI, but it seems to work perfectly as expected. Menu { Picker(selection: $selectedFruit, label: Text("Select Favorite Fruit")) { ForEach(0..<fruits.count, id: \.self) { Text(fruits[$0]) } } } label: { HStack { Text("Favorite Fruit") Divider() Text(fruits[selectedFruit]) } } Source: https://stackoverflow.com/q/70835085
Aug ’22
Reply to Picker Label not showing anymore
Using the Picker in a Form renders the label as @Merlin52 pointed out. The Form really takes over your design though, which is nice but not when you need to customize it. Here's another sample with a screenshot: struct ContentView: View { var fruits = ["Banana","Apple", "Peach", "Watermelon", "Grapes" ] @State private var selectedFruit = 0 var body: some View { Form { // Variation 1 Picker(selection: $selectedFruit, label: Text("Select Favorite Fruit")) { ForEach(0..<fruits.count, id: \.self) { Text(self.fruits[$0]) } } // Variation 2 Picker(selection: $selectedFruit) { ForEach(0..<fruits.count, id: \.self) { Text(self.fruits[$0]) } } label: { HStack { Text("Favorite Fruit") Divider() Text(fruits[selectedFruit]) } } // Variation 3 Menu { ForEach(0..<fruits.count, id: \.self) { Text(self.fruits[$0]) } } label: { HStack { Text("Favorite Fruit") Divider() Text(fruits[selectedFruit]) } } } .pickerStyle(.menu) } } Here's how everything looks like when I nest everything in a VStack instead of a Form: Notice I added a Menu in there, which seems like the behaviour the OP is expecting. Shouldn't the Picker mimic that behaviour when modified with a MenuPickerStyle? This would mean the label parameter could be optional in the Picker initializer (so it can default to displaying the selected row). Repurposing a Menu as a picker is the painful alternative in the meantime.
Aug ’22
Reply to CLKRelativeDateTextProvider values get truncated in circular complications
This is still a bug in watchOS 8. I relied offsetShort but still same problem. It displays fine in the simulator as "28M", but on a real device, it insists in trying to display "28 MIN" which gets truncated to "28..." You can run it in a simulator and real device to see the issue: CLKComplicationTemplateGraphicCircularOpenGaugeSimpleText( gaugeProvider: CLKTimeIntervalGaugeProvider( style: .ring, gaugeColors: nil, gaugeColorLocations: nil, start: Date() - 2000, startFillFraction: 1, end: Date() + 2000, endFillFraction: 0 ), bottomTextProvider: CLKSimpleTextProvider(text: "AB"), centerTextProvider: CLKRelativeDateTextProvider( date: Date() + 1200, style: .naturalAbbreviated, units: [.hour, .minute] ) ) Submitted a feedback and sample project with this code: FB9974072
Apr ’22
Reply to CloudKit watchOS 6 silent notification problem
I'm having the same problem on watchOS 8.4.. silent notifications are not being sent to the watch but works perfectly for iOS. let zoneID = CKRecordZone.ID(zoneName: "Settings", ownerName: CKCurrentUserDefaultName) let subscriptionID = "settings-subscription-id let subscription = CKRecordZoneSubscription(zoneID: zoneID, subscriptionID: subscriptionID) let notificationInfo = CKSubscription.NotificationInfo() notificationInfo.shouldSendContentAvailable = true subscription.notificationInfo  let subscription = try await database.save(subscription) I call WKExtension.shared().registerForRemoteNotifications() in applicationDidBecomeActive and didRegisterForRemoteNotifications(deviceToken:) does fire. However, didReceiveRemoteNotification does not fire. I also tried some suggestions here like updating the provisioning profile at AppConnect for watch app and extension which makes sense. Looking at the iCloud console though, the watch is never able to create subscriptions at iCloud at all! I query "Data > Subscriptions" section in console and only see the iOS subscription created. Does each device need to have their own unique subscription? Because I also tried this by putting the vendor device identifier in the subscription ID so each device creates their own, but the watch still never creates a subscription at the server nor does it error on database.save(subscription). Is there a trick for the watch to create subscriptions at iCloud? I'm using the above code but no errors result from it, but the subscription records never shows up on the iCloud console (but iOS does and receives silent fine). I also have "Supports Running without iOS app" checked if that makes a difference.
Jan ’22
Reply to swift-frontend memory usage
Seems like SwiftUI is tripping up Xcode 13 a lot. Commenting out a random ScrollView or other view sometimes works. swift-frontend process has gone so high to 145GB at one point and I only have 32GB RAM on this machine (Big Sur 11.6.1 / Xcode 13.1).
Nov ’21