NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

Ultimate Portfolio App Issue Custom sorting for items

Forums > SwiftUI

Hi Guys, code has been followed step by step and for some reason the sorting button on pressing just flips out and goes to the home screen when presenting the ActionSheet (however in the swiftUI simulator its working as expected) anyone else seen this? the action sheet works just have to go back in projects.... which shouldbt be happening....weird

Toobar where the action sheet is

                ToolbarItem(placement: .navigationBarTrailing) {
                    if showClosedProjects == false {
                        Button {
                            withAnimation {
                                let project = Project(context: managedObjectContext)
                                project.closed = false
                                project.creationDate = Date()
                        } label: {
                            Label("Add Project", systemImage: "plus")

                ToolbarItem(placement: .navigationBarLeading) {
                    Button {
                    } label: {
                        Label("Sort", systemImage: "arrow.up.arrow.down")
            .actionSheet(isPresented: $showingSortOrder) {
                ActionSheet(title: Text("Sort items"), message: nil, buttons: [
                    .default(Text("Optimized")) { sortOrder = .optimized },
                    .default(Text("Creation Date")) { sortOrder = .creationDate },
                    .default(Text("Title")) { sortOrder = .title }

all looks fine to me :-(


Hacking with Swift is sponsored by Stream

SPONSORED Check out Stream's cross-platform open source chat SDK on GitHub! Write once and deploy your app with fully featured chat UI on iOS and macOS.

Go to GitHub

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.