Post

Replies

Boosts

Views

Activity

Glitchy page transitions with TabView on watchOS
We're trying to implement transitions between TabView pages similar to what the Fitness app does on watchOS. As the user swipes or uses the Digital Crown to move between pages, the large rings gauge in the center transitions smoothly to a toolbar item. The code to implement this transition is described in two places in Apple's documentation: https://developer.apple.com/documentation/watchos-apps/creating-an-intuitive-and-effective-ui-in-watchos-10 (See the section “Provide continuity with persistent elements”) The WWDC23 session "Design and build apps for watchOS 10", around 9:30 However, copying the code from Apple's documentation doesn't give animation as reliable as what we're seeing in the Fitness app. Any slight reversal of motion causes the transition animation to jump back to the starting state. Has anyone else figured out how to replicate what the Fitness app is doing on watchOS? I've included our View implementation below. Debug prints show what's going wrong: the page variable decrements immediately the user moves backward by any amount. But somehow, the Fitness app gets around this problem. How? struct ContentView: View { @Namespace var namespace @State var page = 0 var body: some View { NavigationStack { TabView(selection: $page) { globeView .containerBackground(Color.blue.gradient, for: .tabView) .navigationTitle("One") .matchedGeometryEffect( id: "globe", in: namespace, properties: .frame, isSource: page == 0) .tag(0) Text("Page two") .containerBackground(Color.green.gradient, for: .tabView) .navigationTitle("Two") .tag(1) } .tabViewStyle(.verticalPage) .toolbar { ToolbarItem(placement: .topBarLeading) { globeView .matchedGeometryEffect( id: "globe", in: namespace, properties: .frame, isSource: page == 1) } } } } @ViewBuilder var globeView: some View { Image(systemName: "globe") .resizable() .scaledToFit() } } Thanks for any help! —Chris
0
0
204
Sep ’24
New UI Element colors in SwiftUI
Is there an easy way to get the new adaptive UI element colors (systemBackground, secondaryLabel, etc.) in SwiftUI? I know that I could write a class to bridge to UIColor and do the getRed(green:blue:alpha:) dance, but it seems like there should be a simpler approach. I know understand that these colors are used automatically in some cases, but it seems like custom controls would benefit from having them available. Am I misunderstanding the role of the UI element colors in SwiftUI?—Chris
10
1
8.4k
Jun ’19
NSURLSession downloads to inaccessible file
I'm using an NSURLSession for background downloads, and even though the download is apparently successful, didFinishDownloadingToURL is giving a URL that the app doesn't have permission to access. An example:/var/mobile/Library/Caches/com.apple.nsurlsessiond/Downloads/com.company.appname/CFNetworkDownload_u0dx1W.tmpUsually, downloads are successful. In that case, the URL from didFinishDownloadingToURL looks like this:/private/var/mobile/Containers/Data/Application/xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx/Library/Caches/com.apple.nsurlsessiond/Downloads/com.company.appname/CFNetworkDownload_u0dx1W.tmpThe big problem is that once I start getting bad URLs, nsurlsessiond seems to be stuck in that state. Failures continue even after rebooting the device or deleting and reinstalling the app. I've observed this problem with iOS 10.2 and the iOS 10.3 betas. Has anyone seen something similar and found a workaround? This really looks to me like an iOS bug.—Chris
19
0
7k
Mar ’17