Post

Replies

Boosts

Views

Activity

Collapse sidebar in SwiftUI (Xcode 12)
I'm trying to do a simple application in SwiftUI taking advantage of SwiftUI 2.0's new multiplatform project template, and I wish to add the option to collapse the sidebar as many other apps do. I've got an extremely simple sidebar I did following the Fruta example project, and I tried adding a boolean state variable that controls whether the sidebar should show or not, but that doesn't work because when the sidebar is hidden, the main view is turned translucent. On iPadOS, a button appears on top of the sidebar that allows to collapse it. How would I do this in macOS? Is there a way to natively achieve this in SwiftUI, or I'll need to resort to a UIKit workaround?  Please note I'm using macOS Big Sur, Xcode 12, and SwiftUI 2.0 Thanks in advance.
11
0
9k
Jul ’21
SwiftUI crashes when there are two navigationLinks in one view
My team and I are currently developing a Mastodon client in SwiftUI and I've got a simple StatusView where I display all the post data. This view, known on my project as StatusView, has two NavigationLinks: The main one, that redirects the user to the post's thread, and one that redirects the user to the post's author's profile when the post's profile picture is tapped. Until here, everything works fine. If you tap anywhere on the post that aren't the buttons (like, boost, and share) or the profile picture, it opens the thread. If you tap on the profile picture, it opens the author's profile. But if you tap below the profile picture, the app crashes, only giving me the following error: 2020-08-23 21:32:39.929392-0400 Hyperspace[830:147862] WF: _WebFilterIsActive returning: NO 2020-08-23 21:32:40.117865-0400 Hyperspace[830:147862] [assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist}> 2020-08-23 21:32:40.117994-0400 Hyperspace[830:147862] [ProcessSuspension] 0x11decfa80 - ProcessAssertion: Failed to acquire RBS Background assertion 'WebProcess Background Assertion' for process with PID 837, error: Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist} 2020-08-23 21:32:40.119401-0400 Hyperspace[830:147862] [assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist}> 2020-08-23 21:32:40.119549-0400 Hyperspace[830:147862] [ProcessSuspension] 0x11decfac0 - ProcessAssertion: Failed to acquire RBS Suspended assertion 'WebProcess Suspended Assertion' for process with PID 837, error: Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist} Fatal error: UIKitNavigationBridge: multiple active destinations: file SwiftUI, line 0 2020-08-23 21:32:40.292135-0400 Hyperspace[830:147862] Fatal error: UIKitNavigationBridge: multiple active destinations: file SwiftUI, line 0 I guess this is because when you tap there, both the thread's and the profile's navigation links are triggered, causing the app to crash because there are multiple active destinations, as it's trying to go to the thread and to the profile at the same time. TL;DR My app crashes because two NavigationLinks are triggered at the same time when they shouldn't. How can I fix this? Thanks in Advance. My Code My Code - https://developer.apple.com/forums/content/attachment/97a69433-ae8d-4aa7-9921-2ceba4d3eb4c
0
0
2.5k
Aug ’20