Post

Replies

Boosts

Views

Activity

Too many entries for NavigationStack
Hi there, I am currently programming an app for certain medication usage for paramedics in my region. For that, I made a List inside a NavigationStack with NavigationLinks to further Swift files, each one for one drug. The problem is, that when I add more than 16 NavigationLinks to the NavigationStack, the app stops working and crashes. Is it too much code or do I have to do anything else? I am very new to programming in general so I would love to hear from you! Greetings Laurin Here is the code: // // Medikamente.swift // SAA Medikamente // // Created by Laurin Bräunig on 18.10.23. // import SwiftUI struct Medikamente: View { var body: some View { // Medikamentenliste NavigationStack { //Medikamente List { NavigationLink(destination: Acetylsalicylsaeure()){ Text("Acetylsalicylsäure") } NavigationLink(destination: Amiodaron()){ Text("Amiodaron") } NavigationLink(destination: Atropin()){ Text("Atropin") } NavigationLink(destination: Butylscopolamin()){ Text("Butylscopolamin") } NavigationLink(destination: Dimenhydrinat()){ Text("Dimenhydrinat") } NavigationLink(destination: Dimentinden()){ Text("Dimentinden") } NavigationLink(destination: Epinephrin()){ Text("Epinephrin") } NavigationLink(destination: Esketamin()){ Text("Esketamin") } NavigationLink(destination: Furosemid()){ Text("Furosemid") } NavigationLink(destination: Glucagon()){ Text("Glucagon") } NavigationLink(destination: Glucose()){ Text("Glucose") } NavigationLink(destination: Glyceroltrinitrat()){ Text("Glyceroltrinitrat") } NavigationLink(destination: Heparin()){ Text("Heparin") } NavigationLink(destination: Ibuprofen()){ Text("Ibuprofen") } NavigationLink(destination: Ipratropiumbromid()){ Text("Ipratropiumbromid") } NavigationLink(destination: Lidocain()){ Text("Lidocain") } .navigationTitle("Medikamente") .navigationBarTitleDisplayMode(.automatic) } } } } #Preview { Medikamente() } Thanks again for your help!
4
0
995
Oct ’23
Unable to open mach-O at path: default.metallib Error:2
Hey there, I am quite new to SwiftUI and currently trying to implement a pdf file into my app. When run the app on my iPhone the pdf file opens without any problems but I always get this Error: Unable to open mach-O at path: default.metallib Error:2 I do not actually understand the code completely I found on multiple websites, but what am I doing wrong? I attached my used code. Thanks for your help! Laurin import PDFKit struct PDFKitView: UIViewRepresentable { let pdfDocument: PDFDocument init(showing pdfDoc: PDFDocument) { self.pdfDocument = pdfDoc } func makeUIView(context: Context) -> PDFView { let pdfView = PDFView() pdfView.document = pdfDocument pdfView.autoScales = true return pdfView } func updateUIView(_ pdfView: PDFView, context: Context) { pdfView.document = pdfDocument } } struct Hypoglykaemie: View { let pdfDoc: PDFDocument init() { let url = Bundle.main.url(forResource: "hypoglykaemie", withExtension: "pdf")! pdfDoc = PDFDocument(url: url)! } var body: some View { PDFKitView(showing: pdfDoc) } } #Preview { Hypoglykaemie() }
2
0
2.5k
Oct ’23
Language settings for back Button
Hey there, I am quite new to SwiftUI and I am currently programming an app with several NavigationLinks. The app should be in German in the end, but I have no idea how I can translate the back buttons into other languages. Can someone help? Thank you so much! Laurin
2
0
889
Oct ’23
SwiftUI animation bug
Hi there, I am still quite new to Swift and have following problem: Many animations in my app have bugs, like you can see in the attached images. I cannot attach a video so I attached images from the video. Here is my description: When I click on a NavigationLink, the title of the following page appears after the animation and the whole content of the page moves up. What can I do against this? This is my code from the first page: struct Medikamente: View { var body: some View { NavigationStack { List { Group { NavigationLink(destination: Acetylsalicylsaeure()){ Image("AcetylsalicylsaeureMediLabel") .resizable() .frame(width:60, height: 30) Text("Acetylsalicylsäure") } NavigationLink(destination: Amiodaron()){ Image("AmiodaronMediLabel") .resizable() .frame(width:60, height: 30) Text("Amiodaron") } NavigationLink(destination: Atropin()){ Image("AtropinMediLabel") .resizable() .frame(width:60, height: 30) Text("Atropin") } NavigationLink(destination: Butylscopolamin()){ Image("ButylscopolaminMediLabel") .resizable() .frame(width:60, height: 30) Text("Butylscopolamin") } // More medication } } .navigationTitle("Medikamente") .navigationBarTitleDisplayMode(.automatic) } } } #Preview { Medikamente() } And this is the code from the second page. struct Acetylsalicylsaeure: View { var body: some View { NavigationStack { List { Section { Image("AcetylsalicylsaeureMediLabel") .resizable() .scaledToFit() } NavigationLink(destination: List { Section { Text("**500 mg Trockensubstanz** + 5ml Lösungsmittel") Text("diverse orale Darreichungsformen") } header: { Text("**Allgemeine Informationen** \nKonzentration") } Section { Text("Thrombozytenaggregationshemmer") } header: { Text("Arzneimittelgruppe") } .navigationTitle("Acetylsalicylsäure") .navigationBarTitleDisplayMode(.inline) }) { Text("Allgemeine Informationen") } // More NavigationLinks... NavigationLink(destination: List { Section { Text("Im Rettungsdienst nicht möglich") } header: { Text("**Erfolgsprüfung**") } .navigationTitle("Acetylsalicylsäure") .navigationBarTitleDisplayMode(.inline) }) { Text("Erfolgsprüfung") } NavigationLink(destination: List { Section { Text("Lt. BPR „Akutes Coronarsyndrom“, Heparin 5.000 I.E. i.v.") } header: { Text("**Folgemaßnahmen**") } .navigationTitle("Acetylsalicylsäure") .navigationBarTitleDisplayMode(.inline) }) { Text("Folgemaßnahmen") } .navigationTitle("Acetylsalicylsäure") .navigationBarTitleDisplayMode(.inline) } } } } #Preview { Acetylsalicylsaeure() } Thank you so much for your help! Laurin
1
0
775
Oct ’23
SwifftUI iPadOS landscape view bug
Hi there, I am currently developing an app for iPhone and iPad. I made a sidebar with various items which are linked to other pages via NavigationLink. The problem is, that as soon as I scroll down, the app crashes. This is only happening in landscape mode on the iPad. What am I doing wrong? Thank you for your help! Here is my code: var body: some View { NavigationView { List { Group { NavigationLink(destination: Acetylsalicylsaeure()){ Image("AcetylsalicylsaeureMediLabel") .resizable() .frame(width:60, height: 30) Text("Acetylsalicylsäure") } NavigationLink(destination: Amiodaron()){ Image("AmiodaronMediLabel") .resizable() .frame(width:60, height: 30) Text("Amiodaron") } NavigationLink(destination: Atropin()){ Image("AtropinMediLabel") .resizable() .frame(width:60, height: 30) Text("Atropin") } NavigationLink(destination: Butylscopolamin()){ Image("ButylscopolaminMediLabel") .resizable() .frame(width:60, height: 30) Text("Butylscopolamin") } NavigationLink(destination: Dimenhydrinat()){ Image("DimenhydrinatMediLabel") .resizable() .frame(width:60, height: 30) Text("Dimenhydrinat") } NavigationLink(destination: Dimentinden()){ Image("DimentindenMediLabel") .resizable() .frame(width:60, height: 30) Text("Dimentinden") } NavigationLink(destination: Epinephrin()){ Image("EpinephrinMediLabel") .resizable() .frame(width:60, height: 30) Text("Epinephrin") } NavigationLink(destination: Esketamin()){ Image("EsketaminMediLabel") .resizable() .frame(width:60, height: 30) Text("Esketamin") } } // More NavigationLinks... Group { NavigationLink(destination: Midazolam()){ Image("MidazolamMediLabel") .resizable() .frame(width:60, height: 30) Text("Midazolam") } NavigationLink(destination: Naloxon()){ Image("NaloxonMediLabel") .resizable() .frame(width:60, height: 30) Text("Naloxon") } NavigationLink(destination: Paracetamol()){ Image("ParacetamolMediLabel") .resizable() .frame(width:60, height: 30) Text("Paracetamol") } NavigationLink(destination: Prednisolon()){ Image("PrednisolonMediLabel") .resizable() .frame(width:60, height: 30) Text("Prednisolon") } NavigationLink(destination: Salbutamol()){ Image("SalbutamolMediLabel") .resizable() .frame(width:60, height: 30) Text("Salbutamol") } NavigationLink(destination: Sauerstoff()){ Image("SauerstoffMediLabel") .resizable() .frame(width:60, height: 30) Text("Sauerstoff") } NavigationLink(destination: Urapidil()){ Image("UrapidilMediLabel") .resizable() .frame(width:60, height: 30) Text("Urapidil") } NavigationLink(destination: Vollelektrolytloesung()){ Image("VollelektrolytloesungMediLabel") .resizable() .frame(width:60, height: 30) Text("Vollelektrolytlösung") } } } .listStyle(SidebarListStyle()) .navigationTitle("Medikamente") BackgroundMedikamente() } } }
0
0
451
Oct ’23
NavigationLink from PDF
Hi there, I am currently developing an app. I would like to make NavigationLinks from certain words inside an implemented .pdf-file to other Swift view files. Is there a possibility to do this? Here is my code: import PDFKit struct BasismassnahmenPDF: UIViewRepresentable { let pdfDocument: PDFDocument init(showing pdfDoc: PDFDocument) { self.pdfDocument = pdfDoc } func makeUIView(context: Context) -> PDFView { let pdfView = PDFView() pdfView.document = pdfDocument pdfView.autoScales = true return pdfView } func updateUIView(_ pdfView: PDFView, context: Context) { pdfView.document = pdfDocument pdfView.minScaleFactor = 0.6 pdfView.scaleFactor = pdfView.scaleFactorForSizeToFit } } struct Basismassnahmen: View { let pdfDoc: PDFDocument init() { let url = Bundle.main.url(forResource: "Basismassnahmen", withExtension: "pdf")! pdfDoc = PDFDocument(url: url)! } var body: some View { BasismassnahmenPDF(showing: pdfDoc) } } #Preview { Basismassnahmen() } Thank you so much for your help! Laurin
0
0
497
Oct ’23
Different symbols for different iOS-Versions.
Hi there, I am currently developing an app with a tab view. Unfortunately some the symbols I use only work for iOS 17. I would like to change a symbol but only for iOS 16. Is this possible? Thank you for your help! Laurin Here is my code: struct ContentView: View { var body: some View { TabView { Group { Medikamente() .tabItem { Image(systemName: "syringe") Text("Medikamente") } BPR() .tabItem { Image(systemName: "point.bottomleft.forward.to.arrowtriangle.uturn.scurvepath") Text("BPR") } InvasiveMassnahmen() .tabItem { Image(systemName: "heart.text.square") Text("Maßnahmen") } } } } } #Preview { ContentView() }
1
0
464
Oct ’23
Combine views in SwiftUI
Hi there, I am still quite new to Swift and want to combine a few views into one single view. But the problem is, that if I do it like in the following code, there are windows for each view. Is there a chance to code it that it is one coherent view where I can scroll through? Thank you for your help! Laurin @AppStorage("MediAnsicht") var MedisEinfacheAnsicht = false var body: some View { if MedisEinfacheAnsicht == true { AcetylsalicylsaeureAllgInfos() AcetylsalicylsaeureKontraind() AcetylsalicylsaeureUAWs() } else { AcetylsalicylsaeureMenu() } } }
2
0
517
Nov ’23
Implement .searchable into existing list in SwiftUI
Hi there, I would like to implement a search bar into my existing list, filled with NavigationLinks. Is there a possibility to mark all my existing NavigationLinks with variables that I can show them in my search list? I am still quite new to SwiftUI so I would love to hear from you. Here is my code: var body: some View { NavigationView { List { Group { NavigationLink(destination: MidazolamLink()){ Image("MidazolamMediLabel") .resizable() .frame(width:60, height: 30) Text("Midazolam") } NavigationLink(destination: NaloxonLink()){ Image("NaloxonMediLabel") .resizable() .frame(width:60, height: 30) Text("Naloxon") } NavigationLink(destination: ParacetamolLink()){ Image("ParacetamolMediLabel") .resizable() .frame(width:60, height: 30) Text("Paracetamol") } NavigationLink(destination: PrednisolonLink()){ Image("PrednisolonMediLabel") .resizable() .frame(width:60, height: 30) Text("Prednisolon") } NavigationLink(destination: SalbutamolLink()){ Image("SalbutamolMediLabel") .resizable() .frame(width:60, height: 30) Text("Salbutamol") } NavigationLink(destination: SauerstoffLink()){ Image("SauerstoffMediLabel") .resizable() .frame(width:60, height: 30) Text("Sauerstoff") } NavigationLink(destination: UrapidilLink()){ Image("UrapidilMediLabel") .resizable() .frame(width:60, height: 30) Text("Urapidil") } NavigationLink(destination: VollelektrolytloesungLink()){ Image("VollelektrolytloesungMediLabel") .resizable() .frame(width:60, height: 30) Text("Vollelektrolytlösung") } } } .background(Color.clear) .listStyle(SidebarListStyle()) .navigationTitle("Medikamente") .toolbar { NavigationLink(destination: About()){ Image(systemName: "info.circle") } NavigationLink(destination: Settings()){ Image(systemName: "gear") } } BackgroundMedikamente() } } } Thank you so much for your help! Laurin
2
0
620
Nov ’23
Remove list headers in .searchable
Hi there, I am still quite new to SwiftUI and made a .searchable list as you can see in my code below. When I search, all list headers are displayed, even if there aren't any results in that list. How can I fix that? Thank you for your help! Laurin //Herangehensweise "basismaßnahmen", "cabcde herangehensweise", "cabcde instabilitäten", "beurteilung der bewusstseinslage", "sampler", "opqrst", "atemwegsmanagement", "patientenanmeldung", //Kreislaufstillstand "erwachsene bls reanimation", "erwachsene als mit manueller defibrillation reanimation", "erwachsene als mit aed reanimation", "kinder pls reanimation", "neugeborene pls baby reanimation", "postreanimationstherapie rosc", //Leitsymptome "dyspnoe atemnot luft", "kritische blutung tourniquet", "kurzzeitige bewusstlosigkeit synkope tloc", "nichttraumatischer brustschmerz thorax acs akutes aortensyndrom lungenembolie lae spontanpneumothorax spannungspneumothorax", "schock blut volumenmangel blutdruck hypoton blutverlust", "starke schmerzen nrs analgesie analgosedierung midazolam dormicum esketamin ketanest", "zentrales neurologisches defizit bewusstlosigkeit", //Krankheitsbilder //More entries... ] struct BPR: View { var bprs: [String] { let lcBprs = listOfBPRs.map { $0.lowercased() } return searchText == "" ? lcBprs : lcBprs.filter { $0.contains(searchText.lowercased()) } } private var listOfBPRs = bprlist @State var searchText = "" var body: some View { NavigationView { List { Group { Section (header: Text("Herangehensweise")){ ForEach(bprs, id: \.self) { bpr in if bpr.contains("basismaßnahmen") { NavigationLink(destination: Basismassnahmen()) { Label { Text("Basismaßnahmen") } icon: { Image(systemName: "list.bullet.clipboard") } } } else if bpr.contains("cabcde herangehensweise"){ NavigationLink(destination: cabcdeHerangehensweise()) { Label { Text("cABCDE-Herangehensweise") } icon: { Image(systemName: "abc") } } } else if bpr.contains("cabcde instabilitäten"){ NavigationLink(destination: cabcdeInstabilitaeten()) { Label { Text("cABCDE-Instabilitäten") } icon: { Image(systemName: "textformat.abc.dottedunderline") } } } //More else if statements and groups... } } } } } .searchable(text: $searchText) .disableAutocorrection(true) .background(Color.clear) .listStyle(SidebarListStyle()) .navigationTitle("Behandlungspfade") .navigationBarTitleDisplayMode(.automatic) .toolbar { NavigationLink(destination: About()){ Image(systemName: "info.circle") } NavigationLink(destination: Settings()){ Image(systemName: "gear") } } BackgroundMedikamente() } } }
2
0
875
Nov ’23
Fan Speed on Fedora Asahi Remix
Hi there, I have got a question but I don't know if this is the right place. I am using an M1 Mac mini and have installed Fedora Asahi Remix for certain developing Tasks next to MacOS. How is the fan speed controlled? Does Fedora turn on the fan when the CPU gets warm or does the hardware firmware set the fan speed? Thank you for your answers! Laurin
1
0
644
Mar ’24