Post

Replies

Boosts

Views

Activity

List with Sections output weird results?
Hi, This is my first time using a list with different sections. I am using an example from a documented video that I found on the Internet. I'm getting some weird results. Could someone point me in the right direction? Here's the code: import Foundation struct History: Identifiable, Hashable { var id = UUID() var hist: String } struct Titles: Identifiable, Hashable { var id = UUID() var Titl: String } struct Library: Identifiable, Hashable { var id = UUID() var lib: String } // Main Menu Options: var commandsA: [History] = [History(hist: "History"), History(hist: "Overview")] var commandsB: [Titles] = [Titles(Titl: "Title 1: Employment"), Titles(Titl: "Title 2: Public Service" ), Titles(Titl: "Title 3: Public Accommidations"), Titles(Titl: "Title 4: Telecommunication"), Titles(Titl: "Title 5: Miscellous")] var commandsC: [Library] = [Library(lib: "2010 Accessibilty Standards"), Library(lib: "2008 ADA Amendments"), Library(lib: "Phone Numbers"), Library(lib: "More Information")] struct MainMenu160: View { @State private var path = NavigationPath() var body: some View { NavigationStack(path: $path) { List { Section(header: Text("Overview")) { ForEach(commandsA) { secA in HStack { Image(systemName: "folder") Text("\(secA.hist)") }.font(.system(size: 20, weight: .bold, design: .rounded)) } } } List { Section(header: Text("Titles:")) { ForEach(commandsB) { secB in HStack { Image(systemName: "folder") Text("\(secB.Titl)") }.font(.system(size: 20, weight: .bold, design: .rounded)) } } } List { Section(header: Text("Library:")) { ForEach(commandsC) { secC in HStack { Image(systemName: "folder") Text("\(secC.lib)") }.font(.system(size: 20, weight: .bold, design: .rounded)) } } }.navigationTitle("ADA 1990") .navigationBarTitleDisplayMode(.automatic) } } struct MainMenu160_Previews: PreviewProvider { static var previews: some View { MainMenu160() } } } And here's the output:
1
0
610
Feb ’23
SwiftUI: Extra line in NavigationStack
Hi, I know its a simple thing, but I cannot figure it out. I have a list of items going to another view using NavigationStack. Everything seems fine, but when I go into the list, I have two back buttons, the title is shifted down, and its just annoying. Thanks for the help. Here's my code: struct ImportantNumbers: View {      var body: some View {          NavigationStack {       List(INDDataService.getAll(), id: \.id) { data in                  NavigationLink(value: data)         {                       HStack {                          Image(systemName: "circle.fill")               .foregroundColor(.green)                          Text(data.name)               .fontWeight(.bold)                                         .navigationTitle("Important U.S. ADA Numbers")               .navigationBarTitleDisplayMode(.inline)           }                            .navigationDestination(for: INDData.self) {  data in                                  Spacer()                                  Image(data.logo)                   .resizable()                   .frame(width: 200, height: 200)                                  Spacer()                                  Text(data.phone)                   .font(.system(size: 30, weight: .bold, design: .rounded))                                  Spacer()                                    .navigationTitle(data.name)                                }                                                    }                               }       }            }        } struct ImportantNumbers_Previews: PreviewProvider {     static var previews: some View {         ImportantNumbers()     } }
2
0
858
Dec ’22
iOS 16, AVFoundation, Text-to-Speech
Hi, I've been having problems with the AVFoundation and getting text to speech to work with iOS 16. I have a button which activates the text to speech that says the time. It worked with iOS 15 but not 16. Anyone else having a problem? Here's the code: (Note: dtd is coming from another Swift file). import Foundation import AVFoundation struct SUINightMode: View {      @ObservedObject var dtd = DateTimeData()      @Environment(\.presentationMode) var presentationMode      @State private var date = Date()        var body: some View {              ZStack {                  Color.black                    .ignoresSafeArea()                  GeometryReader { cen in                    VStack (alignment: .center) {                  Text("\(dtd.timeString(date: dtd.date))")             .foregroundColor(.green)           .font(.system(size: 120, weight: .bold, design: .rounded))           .alignmentGuide(VerticalAlignment.center, computeValue: { $0[.bottom] })                               .position(x: cen.size.width / 2, y: cen .size.height / 2)           HStack(alignment: .center) {           Text("\(dtd.dayString(date: dtd.date)), ")             .foregroundColor(.green)             .font(.system(size: 50, weight: .bold, design: .rounded))             Text("\(dtd.dateString(date: dtd.date))")             .foregroundColor(.green)           .font(.system(size: 50, weight: .bold, design: .rounded))     }     }       Image(systemName: "speaker.wave.3.fill")           .resizable()           .foregroundColor(.green)           .frame(width: 50, height: 30)           .padding(10)           .position(x: 120, y: 40)           .onTapGesture {             let synthesizer = AVSpeechSynthesizer()             let speakTime = AVSpeechUtterance(string: "The time is, \(dtd.timeString(date: dtd.date))...., today is \(dtd.dayString(date: dtd.date)) \(dtd.dateString(date: dtd.date))")             synthesizer.speak(speakTime)           }       Image(systemName: "arrow.left")           .resizable()           .foregroundColor(.green)           .frame(width: 45, height: 30)           .position(x: 40, y: 40)       .onTapGesture {         presentationMode.wrappedValue.dismiss()       }       .onAppear(perform: {let _ = self.dtd.updateTimer})       }     }       } } struct SUINightMode_Previews: PreviewProvider {     static var previews: some View {       if #available(iOS 15.0, *) {         SUINightMode()           .previewInterfaceOrientation(.landscapeRight)       } else {         // Fallback on earlier versions       }     } }
2
0
1.2k
Oct ’22
Having trouble with first time Mac App's Quit Function
Hi, I'm in the process of writing my first Mac Menu Bar app. I must include a way to quit the app by the normal [Command+Q] option. I got the below code from a YouTube video and it works on the video, but not in my app. I am also using SwiftUI. The code's filename is ApplicationMenu.swift and is written in Swift. According to the video (which I cannot include in this message) the below example shows the menu appearing at the bottom of the window, but when I do it, it doesn't show up. Thank you. Here's the code: import SwiftUI class ApplicationMenus: NSObject { let menu = NSMenu() func createMenu() -> NSMenu   {     let clockView = ActualClock()     let topView = NSHostingController(rootView: clockView)     topView.view.frame.size = CGSize(width: 255, height: 255)     let customMenuItem = NSMenuItem()     customMenuItem.view = topView.view     menu.addItem(customMenuItem)     menu.addItem(NSMenuItem.separator())     let aboutMenuItem = NSMenuItem(title: "About",                                    action: #selector(about),                                    keyEquivalent: "")     aboutMenuItem.target = self     menu.addItem(aboutMenuItem)     return menu   }   @objc func about(sender: NSMenuItem)   {     NSApp.orderFrontStandardAboutPanel()   }   @objc func support(sender: NSMenuItem)   {     NSApp.orderFrontStandardAboutPanel()   } }
1
0
709
Aug ’22
Xcode Version 14.0 beta 2 (14A5229c) Warning
Hi, I'm trying to run.a project in Xcode 14 and I keep getting this warning:: warning build: Skipping duplicate build file in Copy Bundle Resources build phase: /Users/danuff/Documents/CPS/CPS-iOS/iOS 16/Projects (Current)/iPhone : iPad/SwiftUI/General/CAI/CAI/Databases/Phone List Data/JSON Data/UKPhoneNumbersList.json and the project won't run. How can I resolve this? Thanks, Dan Uff P.S. If this is in the wrong forum, I tried to find the Beta one but couldn't. Thanks.
1
0
885
Jun ’22
*** BEWARE OF XCODE 13.3 (13E113) ***
Hi, I am writing this to WARN other developers about a problem that I have run into with Xcode 13.3 (13e113). Ever since downloading this version, I have noticed that my apps have bloated in size. From 23mb to 55mb and above. After an investigation, I noticed that Xcode was duplicating project and other files. Such as [nameofproject] [nameofproject2], etc. Because of this, not only did my project get bloated, but when I try to delete some of the duplicate files (yes, I know what to delete and what NOT too) this would then allow Xcode to delete even MORE FILES each time I went into the project. There is nothing worse then going into a project that you've worked MONTHS on and seeing RED FILES inside the project (red files means not there). So, I keep backups of all my apps. Restoring these backups cause the same problems. This is a notice to all developers -> CHECK YOUR PROJECT FILES FROM THE FINDER so you don't experience this problem. I would HOPE someone from Apple will see AND READ this and maybe even CONTACT ME so I can make DAMN sure this never happens again. Thank you, Dan Uff
4
0
1.5k
Mar ’22
Updated code for Sharesheet in iOS 15?
I'm trying to display a share sheet and am using examples from the Internet but am getting the following warning: "'windows' was deprecated in iOS 15.0: Use UIWindowScene.windows on a relevant window scene instead" Here's the code I'm trying to use: func shareButton() {   let url = URL(string: introText)   let av = UIActivityViewController(activityItems: [url!], applicationActivities: nil)  UIApplication.shared.windows.first?.rootViewController?.present(av, animated: true, completion: nil) } Thanks, Dan Uff
5
0
3k
Nov ’21
No Navigation Bar with List in SwiftUI
Hi all, I've been working on an app for months and have recently came across the below problem. I have a listView with a NavigationView in SwiftUI. When I go into the list, there is NO NavigationBar title or Buttons above it. When I start to scroll, it appears, and then disappears when I go to the top of the list. It has suddenly appeared without any rhyme or reason. I have seen this question asked before and a solution. I have tried it and it still is a problem. Here's the code: import Foundation struct MainMenu: View {       @State private var mainOptions: Int? = 0   @State private var tag: Int = 0   var fSize = Int(20)       var body: some View {           NavigationView() {                      List {                    Section(header: Text("MAIN INFORMATION"))         {                       NavigationLink(destination: Introduction(), tag:1, selection: $mainOptions) {                         Image(systemName: "doc")            Text("Introduction")              .bold()                      }                       NavigationLink(destination: BeSafe(), tag:2, selection: $mainOptions)            {              Image(systemName: "doc")              Text("Be Safe")                .bold()            }                        NavigationLink(destination: MythsAndFacts(), tag:3, selection: $mainOptions)            {              Image(systemName: "doc")              Text("Myths and Facts")                .bold()            }                        NavigationLink(destination: CycleofViolence(), tag:4, selection: $mainOptions)            {              Image(systemName: "doc")              Text("Cycle of Violence")                .bold()            }                        NavigationLink(destination: Definition(), tag:5, selection: $mainOptions)            {              Image(systemName: "doc")              Text("Definitions")                .bold()            }                        NavigationLink(destination: PersonalSafetyPlan(), tag:6, selection: $mainOptions)            {              Image(systemName: "doc")              Text("Personal Safety Plan")                .bold()            }                        NavigationLink(destination: PPOs(), tag:7, selection: $mainOptions)            {              Image(systemName: "doc")              Text("PPOs")                .bold()            }                        NavigationLink(destination: QuestionsOnLeaving(), tag:8, selection: $mainOptions)            {              Image(systemName: "doc")              Text("Questions on Leaving")                .bold()            }                        NavigationLink(destination: AbuseMenu(), tag:9, selection: $mainOptions)            {              Image(systemName: "doc")              Text("Information on Abuse")                .bold()            }                    }            Section(header: Text("GET MORE INFORMATION"))            {                            NavigationLink(destination: PhoneNumbers())              {                Image(systemName: "phone")                Text("Phone Numbers")                  .bold()              }                            NavigationLink(destination: Search())              {                Image(systemName: "safari")                Text("Search")                  .bold()              }                                        }                        Section(header: Text("TAKE NOTES"))            {              NavigationLink(destination: CPNoteLite())              {                Image(systemName: "note.text")                Text("CPNote Lite")                  .bold()              }                             NavigationLink(destination: CPNoteHelp())                {                  Image(systemName: "questionmark")                  Text("Help with CPNote Lite")                    .bold()                }            }                        Section(header: Text("FOR YOUR PROTECTION"))            {             NavigationLink(destination: HideInfo())                 {                   Image(systemName: "book.closed")                           Text("Hide This App.")                     .bold()                                                 }            }          }                                 }.navigationTitle("Domestic Violence")           .navigationBarTitleDisplayMode(.inline)                     .toolbar           {                          ToolbarItem(placement: .bottomBar)             {               HStack {               Image(systemName: "c.circle")                   .resizable()                   .frame(width: 20, height: 20)               Text("2021 Connecting People Software")                   .font(.custom("", size: 18))               }             }           }         .navigationBarItems(leading: NavigationLink(destination: About(),               label: {               Image(systemName: "info.circle")             .font(.custom("", size: 18))            }), trailing: NavigationLink(destination: Support(),               label: {               Image(systemName: "person.circle")             .font(.custom("", size: 18))              }))          }          } struct MainMenu_Previews: PreviewProvider {     static var previews: some View {         MainMenu()       .previewInterfaceOrientation(.portrait)     } } Thank you, Dan Uff
0
0
919
Nov ’21
Cannot install app on test device
Hi, When I try to install a app that I want to test on an iPhone 13, I get the following error: ` Showing All Messages The file "/Users/danuff/Documents/CPS/iOS/iOS 15/Projects (Current)/iPhone : iPad/SwiftUI/General/DVP/DVP/DVP.entitlements" could not be opened. Verify the value of the CODE_SIGN_ENTITLEMENTS build setting for target "DVP" is correct and that the file exists on disk. The app is not installed on the actual device, but it does work on the Simulator.' It worked fine the other day. Thanks, Dan Uff
0
0
612
Nov ’21