Post

Replies

Boosts

Views

Activity

SwiftUI macOS simple NavigationStack and NavigationLink -> problem on multiplatform project
I had a problem with my app (or in my setup) and searching the web I found a very simple code where part of my problem occurs. I create a new Multiplatform App and paste this code in ContentView. import SwiftUI struct ContentView: View { var body: some View { NavigationStack { VStack { Text("Navigation article") .font(.title) .padding() NavigationLink("Go to the second view", destination: SecondView()) .padding() } .navigationTitle("First View") } } } struct SecondView: View { var body: some View { Text("This is the Second view") .font(.headline) .padding() .navigationTitle("Second View") } } run on iPhone/ iOS no problem run on a Mac/macOS Going from view 1 to view 2 work, the back arrow on view 2 is there, and it is working but the second time I go to the view 2, the back arrow is gone. after looking closely I can see the Arrow Underneath the S of SecondView. I have tried many things and could not make it work. I post this in a HackingWithSwift forum and somebody tried the code and said it work. so it seems the problem could be related to my setup but I create another user in my computer , same problem and tried it on my another computer, same problem.
Topic: UI Frameworks SubTopic: SwiftUI
7
0
61
Apr ’25
Form - Multiplatform - Alignment off - HStack ?
Not sure what could cause this. the UI align differently running on iPhone versus running on Mac. If I remove the HStack, it works but I still would like to know why, and if there is a way to make it right on both platforms. Thank you here is my code @State private var viewModel = FirmwareSelectionViewModel() var body: some View { Form { Section("Setup Name") { TextField ( "", text: $viewModel.setupName ) .foregroundColor(.green ) .disableAutocorrection(true) .onSubmit { print ("On Submit") } } Section("Battery") { HStack() { Text("Volt") TextField("", value: $viewModel.Vnominal, format: .number) .textFieldStyle(.roundedBorder) .foregroundColor(.green ) #if !os(macOS) .keyboardType(.decimalPad) #endif .onChange(of: viewModel.Vnominal) { viewModel.checkEntryValidity() print("Updated Vnominal: \(viewModel.Vnominal)") } Text("Ah") TextField("", value: $viewModel.batteryCapacity, format: .number) .textFieldStyle(.roundedBorder) .foregroundColor(.green ) #if !os(macOS) .keyboardType(.decimalPad) #endif .onChange(of: viewModel.batteryCapacity) { viewModel.checkEntryValidity() print("Updated Battery Capacity: \(viewModel.batteryCapacity)") } } } Section("Firmware Type") { Picker(selection: $viewModel.selectedType, label: EmptyView()) { ForEach(TypeOfFirmware.allCases) { type in Text(type.rawValue).tag(type as TypeOfFirmware) .foregroundColor(.green ) } } .pickerStyle(SegmentedPickerStyle()) Picker(selection: $viewModel.selectedFirmware, label: EmptyView()) { ForEach(viewModel.availableFirmware) { firmware in Text(firmware.rawValue.capitalized).tag(firmware as Firmware) } } .pickerStyle(SegmentedPickerStyle()) } } .onChange(of: viewModel.selectedType) { viewModel.resetFirmwareSelection() } .navigationTitle("Firmware Selection") } }
Topic: UI Frameworks SubTopic: SwiftUI
0
0
150
Jan ’25
Open source and AppleID
I would like to share my new project on an open source repository like GitHub. it need capabilities like iCloud. The problem is that I would prefer not have my appleid email being send to the open source repository. I saw that I can exclude files but I would be easier if the open source version had no Apple account associated with it. how should I manage the open source version vs the App Store one. Thank you
Topic: Code Signing SubTopic: General
7
0
807
Oct ’24
UIKit to SwiftUI design question: EnvironmentObject versus Protocol-Delegate, notification
I am considering converting my app to SwiftUI  My app receive data via bluetooth every second in my BluetoothManager.  This data is then send via protocol - delegate to another object that do math and other modification to those data.  From there different data are send via protocol or notification to others object to be save to file, other to be send to CoreData , and some to be displayed  So lot's of data move but rarely to be displayed.  Because most of this transfert is between object and rarely view, I wonder which one is better EnvironmentObject or via Protocol and/or  notification  I did look briefly at combine, and I am not sure if I would be able to use that in that case.
0
0
586
Feb ’21
Help with documentation : example: DisclosureGroup
when I read the disclosureGroup documentation , I see struct DisclosureGroup<Label, Content> where Label : View, Content : View in the first part it says label, I dont understand why. I can put a string and it work, But if I put a label I get an error saying it requires that 'Label<Text, Image>' conform to 'StringProtocol' it get worse (for me :-) the second part say "where Label : View, Content : View" for me it says that label conform to view... ? I tried to put a view, it did not work either , with the same error if I use the "Jump to definition" of disclosure, I can see this   public init(@ViewBuilder content: @escaping () -> Content, @ViewBuilder label: () -> Label) then I am totally lost :-) in label I can see struct Label<Title, Icon> where Title : View, Icon : View :-) Title ... a view ? is there a documentation to help me read documentation :-)
11
0
1.5k
Jan ’21