On my Watch app pre-WatchOS 9 I had code as follows:
`
TabView {
NavigationView {
TodayView(model: delegate.model)
.navigationBarTitleDisplayMode(.large)
}
NavigationView {
SettingsView(model: delegate.model)
}
}
.tabViewStyle(.page)
However, for WatchOS 9 I'm using the new NavigationStack like this:
`
NavigationStack {
TabView {
TodayView(model: delegate.model)
.navigationBarTitleDisplayMode(.large)
The issue is, with WatchOS 9 the title always displays as .inline and never large. I've tried embedding a list or scroll view. I've also tried placing a navigationView within the NavigationStack and TabView, that just makes duplicate titles.
So, using the NavigationStack with a TabView on WatchOS 9, how do you get large titles?
Thanks
Post
Replies
Boosts
Views
Activity
I'm trying to create a UI layout and navigation functionality similar to the Apple Fitness app on Apple Watch.
This is all WatchOS 9 so no need for older API support, phew!
I want to have NavigationTitle set for each view in a TabBar.
I want each selected NavigationDestination to hide the TabBar controls and disable swiping when opened.
I want the NavigationTitle and update to remain whilst navigating between Tabs and Childs.
I've created this sample code based off the Building a productivity app for Apple Watch sample code from Apple and other examples on navigation with the new NavigationStack in WatchOS 9, iOS 16 etc...
import SwiftUI
@main
struct Test_Watch_App_Watch_AppApp: App {
@SceneBuilder var body: some Scene {
WindowGroup {
TabView {
NavigationStack {
ScrollView {
VStack {
NavigationLink("Mint", value: Color.mint)
NavigationLink("Pink", value: Color.pink)
NavigationLink("Teal", value: Color.teal)
}
}
.navigationDestination(for: Color.self) { color in
Text("Hello").background(color)
}
.navigationTitle("Colors")
}
NavigationStack {
ScrollView {
VStack {
NavigationLink("headline", value: Font.headline)
NavigationLink("title", value: Font.title)
NavigationLink("caption", value: Font.caption)
}
}
.navigationDestination(for: Font.self) { font in
Text("Hello").font(font)
}
.navigationTitle("Fonts")
}
}.tabViewStyle(.page)
}
}
}
The problem here is, when selecting any of the Navigation Links, the child view still displays the Tab Bar page indicators and allows you to swipe between the tabs, I don't want this. The functionality as I'd like exists int eh Apple Fitness app on the Watch. The app launches in the Activity Tab. You can swipe across to Sharing, select a person, and in that view it's not then possible to swipe straight back to Activity.
I've tried Embedding the whole TabView in a NavigationStack and removing the NavigationStacks per tab. This works as far as fixing the child views hiding the TabBar page indicator controls and swiping. However, it then breaks NavigationTitles on launch and when moving in and out of Childs, so I don't think it should be this way.
Any help very appreciated.
I supported the Always-On display in my app complications from day one but since am continuing to find animation glitches and bugs that have never been fixed and exist currently on WatchOS 8 & 9 (I've tried Series 6 & 8 devices). I'm thinking about scrapping it and just returning the handler(nil).
Does anyone have an example of where they use it and it really adds value to their app complications? And do they have any suggestions to try and work around the glitches?
Thanks
I’m having an issue with an app I’ve developed where it grinds to a halt and freezes when using the TabView with a certain iOS Setting enabled.
To simplify things, I can easily reproduce this with a demo project.
Launch Xcode 12.5, start a new iOS project with swift, swiftUI lifecycle and SwiftUI interface. Then replace the Text code in the content view body with ithe following simple code:
TabView {
Text("Hello, world! Tab 1")
.tabItem {
Label("Tab 1", systemImage: "list.dash")
}
Text("Tab 2")
.tabItem {
Label("Tab 2", systemImage: "list.dash")
}
}
If you launch and run this on device or on the simulator, it all works fine. You can click between the tabs etc…
However, if you navigate to the iPhone settings (and this is available in the simulator) and go Accessibility -> Keyboards -> Full Keyboard Access and toggle this ON, it causes a problem.
When re-opening the app we just made, as soon as you select a tab at the bottom, the app CPU usage jumps to 100%+ and grinds to a halt. The only fix is to force quite the app, but the issue persists on re-launches until you disable Full Keyboard Access.
Is this a bug? Or am I missing something? It seems to have been around throughout iOS 14’s life time.
Thank you
I'd like to override the style of the widget so that my user's preference of dark mode in the app can also apply in the widget.
In the main SwiftUI app I can use:
SceneDelegate.shared?.window!.overrideUserInterfaceStyle = .dark
But I'm not sure how to use that within the Widget extension. Yes I could define alternative for every single color and piece of text, but even things like the widget system background change with light/dark mode all of which I've have to try to check for and adjust.
If I can override the user interface style, my widget would adjust automatically.
I've implemented the steps in the WWDC 2020 Video "Meet Watch Face Sharing" and have managed to add into my app the ability to press a button to add a watch face. This then launches the Apple Watch app showing my complications, but when I then press add, it says Complication not available on your Apple Watch.
I have a Series 5 paired so all faces should be available, I've even implemented a fallback face but that hasn't helped.
In the end all it does is add a blank face to the watch.
Any suggestions?
I've been unable to generate a complication bundle for my iOS and Apple Watch app with the latest Xcode 12 Beta 6 version. I consistently get the error in the title with the following:
2020-09-15 16:58:51.203 clockkitutil[3685:143736] generating gallery complication bundle for (null) at /Users/simon/Documents/gallery.ckcomplication
I've tried this on my own project and I've also downloaded the Apple Sample Coffee Tracker WatchKit app which also exhibits the same problems.
Any help or suggestions? Is this a bug?
I'm trying to set the list row background color in my WatchOS app. I support WatchOS 6.2 & 7. The app is fully SwiftUI.
I currently use listRowPlatterColor. I note that this has been deprecated in WatchOS 7 (although it does still work). My issue is with WatchOS 6.2 building from Xcode 12 Beta 6.
Everything I run on a simulator or device with WatchOS 6.2 I get a crash:
EXCBADACCESS
If I remove any instances of listRowPlatterColor, the crash doesn't occur. Why does something that's been deprecated in WatchOS 7 still work there, but not in WatchOS 6?
// Example code crashes on WatchOS 6.2 but not 7
// When building and running from Xcode 12 beta 6
struct TestView: View {
var body: some View {
List {
Text("Hellow World)"
.listRowPlatterColor(.clear)
}
}
}
https://developer.apple.com/design/resources/
When I access the above link and scroll down to Add Apple Watch Face and select download, I get redirected to an odd AppleConnect page with some reference to box.com
Other resources seem to work fine, am I doing something wrong? I've tried this on Safari and Chrome and signed into and out of my Apple Developer Account
I'm unable to achieve anything like the font size used in the stock templates when trying to create a Circular Gauge in Swift UI. Here is my code for simply displaying three labels. The maximum value label ("101") clips. I can't set a minimumFontScaleFactor on the Text because it's not a proper view. Here is my current code:
struct GaugeSample: View {
var body: some View {
Gauge(value: currentHR, in: minHR...maxHR) {
Image(systemName: "heart.fill")
} currentValueLabel: {
Text("66").complicationForeground()
} minimumValueLabel: {
Text("59")
} maximumValueLabel: {
Text("101")
}
.gaugeStyle(CircularGaugeStyle(tint: Gradient(colors: getGradientColors())))
}
If I just use a previous style complication like this I get the full size text fonts:
let template = CLKComplicationTemplateGraphicCircularOpenGaugeRangeText()
template.centerTextProvider = CLKSimpleTextProvider(text: "99")
template.leadingTextProvider = CLKSimpleTextProvider(text: "40")
template.trailingTextProvider = CLKSimpleTextProvider(text: "120")
template.gaugeProvider = CLKSimpleGaugeProvider(style: .ring, gaugeColors: [UIColor.blue,UIColor.red], gaugeColorLocations: [0.3,0.9], fillFraction: 0.4)
But I want to use the new SwiftUI complications so I can better customize for things like the rendering mode. Any suggestions?
I'm trying to get the individual voltage measurements of an ECG back from Apple HealthKit using new APIs in iOS 14.
I've already managed to use:
let ecgQuery = HKSampleQuery(sampleType: HKObjectType.electrocardiogramType(), predicate: samplePredicate, limit: 0, sortDescriptors: [sortDescriptor]){ (query, results, error) in
which gets me a HKElectrocardiogram object. From this I can see the average heart rate, ECG classification etc...
I now believe I need to pass that object into an HKElectrocardiogramQuery like this:let ecgSample = HKElectrocardiogramQuery(ecg) { (query, result) in
but I can't find any way to extract data from the result data handler. If I put a print in on result, it executes many times but again, I can't extract the data. result is of type HKElectrocardiogramQuery.Result
The documentations pretty sketchy on Apple's developer site with zero examples provided. Any help would be very appreciated.
Cheers
Classically, the demo in the Meet WidgetKit video used a Calendar as an example, where clearly the times to update are simple to calculate based on when the users events will occur.
I'd like to know about the Activity/Fitness Widget. There's no way to tell when a user will burn that next calorie and as far as I can tell, there's still no background observer in HealthKit you can use to call an update on changes. So, with that in mind, how often should I call to update?
This same dilemma applies to ClockKit and WatchOS complications.