Post

Replies

Boosts

Views

Activity

Reply to @FocusState problem
Hi Thanks for getting back to me.. The first snippet create a new record, so does not use @Bindable, but the second snippet is updating the SwiftData record, hence uses @Bindable. I am running iOS 17.5 and using a 15 Plus to test. The probelm is the icon in the keyboard tool bar dims if I select a diffrent TextField and the user can not dismiss. I would attach an image but Iguess that is not allowed. Thanks. Blessings, --Mark .toolbar { ToolbarItemGroup(placement: .keyboard) { Spacer() Button { focus = nil } label: { Image(systemName: "keyboard.chevron.compact.down") } } }
Jun ’24
Reply to @FocusState problem
struct UpdateFormView: View { @Environment(\.dismiss) var dismiss @FocusState private var focus: Field? @Bindable var item: Register private enum Field: Int { case communion, sunCount, weekCount, proper, place, officiant, preacher, server, memo } var body: some View { NavigationStack { ZStack { Color(.purple) .opacity(0.3) .ignoresSafeArea() VStack { DismissView() .padding(.top, 15) Group { Text("Update Service Record") .font(.title) Text("\(item.service)") .font(.title3) DatePicker("", selection: $item.date) .frame(width: 90, alignment: .center) .padding(.bottom, 30) VStack { //static fields TextField("Proper", text: $item.proper) .textFieldStyle(.roundedBorder) .focused($focus, equals: .proper) TextField("Place of service", text: $item.place) .textFieldStyle(.roundedBorder) .focused($focus, equals: .place) HStack { TextField("Presider", text: $item.officiant) .textFieldStyle(.roundedBorder) .focused($focus, equals: .officiant) TextField("Preacher", text: $item.preacher) .textFieldStyle(.roundedBorder) .focused($focus, equals: .preacher) TextField("Server", text: $item.server) .textFieldStyle(.roundedBorder) .focused($focus, equals: .server) } TextField("Memo", text: $item.memo) .textFieldStyle(.roundedBorder) .focused($focus, equals: .memo) Button { dismiss() } label: { Text("Update") } .buttonStyle(.borderedProminent) .font(.title) .padding() Spacer() } .padding() } .navigationBarBackButtonHidden() .toolbar { ToolbarItemGroup(placement: .keyboard) { Spacer() Button { focus = nil } label: { Image(systemName: "keyboard.chevron.compact.down") } } } .onAppear { UITextField.appearance().clearButtonMode = .whileEditing focus = .proper } } } }
Jun ’24
Reply to @FocusState problem
struct ServiceFormView: View { @Environment(\.modelContext) private var context @Environment(\.dismiss) var dismiss @FocusState private var focus: Field? @AppStorage("date") var date = Date() @State private var service = "" @State private var prop = "" @State private var count = "" @State private var place = "" @State private var presider = "" @State private var preacher = "" @State private var server = "" @State private var memo = "" @State private var communions = "" @State private var sundayAdded = false @State private var includeInASA = false @State private var addEuch = false @State private var showError = false var serviceType = ["Select Service", "Sunday Eucharist", "Weekday Eucharist", "Private Eucharist", "Sunday Office", "Weekday Office", "Burial", "Wedding", "Other"] private enum Field: Int, CaseIterable { case prop, count, place, presider, preacher,server, memo, communion } var body: some View { NavigationStack { ZStack { Color(.purple) .opacity(0.3) .ignoresSafeArea() VStack { DismissView() .padding(.top, 15) Group { Text("Enter Service Record") .font(.title) DatePicker("", selection: $date) .frame(width: 90, alignment: .center) .padding(.bottom, 30) VStack(spacing: 12) { Picker("Select Service", selection: $service) { ForEach(serviceType, id: \.self) { service in Text(service).tag(service) } } .buttonStyle(.borderedProminent) } } if service == Constants.serviceList.privateEucharist || service == Constants.serviceList.other{ Toggle("Include in ASA", isOn: $includeInASA) .frame(width: 200) } if service == Constants.serviceList.burial || service == Constants.serviceList.marriage { Toggle("Include in ASA", isOn: $includeInASA) .frame(width: 225) Toggle("Celebrate Eucharist", isOn: $addEuch) .frame(width: 225) if addEuch { Text("Communions: ") TextField("Communions", text: $communions ) .textFieldStyle(.roundedBorder) .focused($focus, equals: .communion) .numbersOnly($communions) .frame(width: 125) } } Text("Attendance: ") .padding(.top, 20) TextField("Count", text: $count) .textFieldStyle(.roundedBorder) .frame(width:125) .numbersOnly($count) .keyboardType(.numberPad) .focused($focus, equals: .count) if service == Constants.serviceList.eucharist || service == Constants.serviceList.weekdayEucharist || service == Constants.serviceList.privateEucharist { Text("Communions: ") TextField("Communions", text: $communions ) .textFieldStyle(.roundedBorder) .focused($focus, equals: .communion) .numbersOnly($communions) .keyboardType(.numberPad) .frame(width: 125) } HStack { TextField("Proper", text: $prop) .textFieldStyle(.roundedBorder) .focused($focus, equals: .prop)} .padding(.top, 30) TextField("Place of service", text: $place) .textFieldStyle(.roundedBorder) .focused($focus, equals: .place) HStack { TextField("Presider", text: $presider) .textFieldStyle(.roundedBorder) .focused($focus, equals: .presider) TextField("Preacher", text: $preacher) .textFieldStyle(.roundedBorder) .focused($focus, equals: .preacher) TextField("Server", text: $server) .textFieldStyle(.roundedBorder) .focused($focus, equals: .server) } TextField("Memo", text: $memo) .textFieldStyle(.roundedBorder) .focused($focus, equals: .memo) Button { addService() dismiss() } label: { Text("Add") } .buttonStyle(.borderedProminent) .font(.title) .disabled(service.isEmpty) .disabled(count.isEmpty) .padding(.top, 30) Spacer() } .padding() } .navigationBarBackButtonHidden() .toolbar { ToolbarItemGroup(placement: .keyboard) { Spacer() Button { focus = nil } label: { Image(systemName: "keyboard.chevron.compact.down") } } } .onAppear { UITextField.appearance().clearButtonMode = .whileEditing focus = .prop } } } }
Jun ’24
Reply to @FocusState problem
Hi, Thanks for checking, sorry I missed it, I did not have Notifications on. I tried to post a response with code, but the forum errored out that I need something in the body. Will try separate posts. The forst one is the code that FocusState works.
Jun ’24
Reply to CloudKit container error
In case others get stuck with this, I created a new container and ensured the container = NSPersistentCloudKitContainer(name: "name") , and the CoreData file was the same name and all went fine afer. I also made sure the container name, et.al. was a short name and was different from the BundleID. Blessings, --Mark
Apr ’23
Reply to After iOS 15.6 update, app fails to load data
Hi, Thanks so much for the reply. To answer your question, I am using try await URLSession.shared.data(from: URL), but I discovered the API call is not the problem. I have been testing when there is no network connection, and I discovered on my iPhone 12 with 15.6.1, at least, when I turn on Airplane mode, it kills the cellular connection on some of my installed apps, including this one. Resetting the network configuration back to the factory settings fixes the issue until I put it back into Airplane mode again. Googling the issue, apparently, others have the same issue with this iOS build. I am relived it was not my code as I was really turning my head upside down trying to figure out what was going on. Thanks. Blessings, --Mark
Sep ’22
Reply to iOS 14 background image not changing.
I make things WAY harder than they need to be! I discovered that I was adding a view (and the memory overhead) each time I changed the image and when the app reset, it just used the last image saved. The simple solution was to ignore the background view and add a UIImageView and change the image to that! Live and learn!
Oct ’20
Reply to iOS 14 background image not changing.
Hi, Thanks for your response. This code is in the initial viewController. A new image can be selected in the settings VC. As I said, it works fine the first time and and when I swipe away the app. I call the method in viewWillAppear. It does run when the view activates, just does not update the image. I would expect the image would be be boded with the image data saved in the defaults every time it is called. Third: I call self.view.insertSubview(backgroundImage, at: 0) so that should insert the image. At least it does the first time and the the app restarts. Thanks. Blessings, —Mark
Oct ’20