Create elegant and intuitive apps that integrate seamlessly with Apple platforms.

All subtopics

Post

Replies

Boosts

Views

Activity

Swiftui Table statement conditional table columns
Is it possible to have conditional table columns for a swifui Table statement? Like for this code TableColumn("Image") { artPiece in if let imageData = artPiece.artImage.first, let image = UIImage(data: imageData!) { Image(uiImage: image) .resizable() .frame(width: 50, height: 50) } else { Image(systemName: "photo") .resizable() .frame(width: 50, height: 50) } } .customizationID("Image") TableColumn("Name", value: \.artName) .customizationID("Name") TableColumn ("Art ID", value: \.artPieceID) { artPiece in Text(String(artPiece.artPieceID)) } .customizationID("Art ID") have a conditional TableColumn for this part of my SWIFTDATA model var artDefinedFields: [ArtDefinedFields] = [] or if I change the variable string array to this var artDefinedFields: [ArtDefinedFields] = Array(repeating: ArtDefinedFields(), count: 10), initialize the array with "None" and only create a TableColumn when there is aArtDeginedFields value other than "None"
3
0
497
Aug ’24
why ToolbarItemGroup appears only on the first tab?
// just check the below code. it's about simplest possible to // looks the same with simulator and real device with iOS 17.1+ import SwiftUI struct MainTabView: View { @FocusState private var focusedField: Bool var body: some View { TabView { TextField("test 1", text: .constant("test 1")) .focused($focusedField) .tabItem { Label("tab 1", systemImage: "number") } .toolbar { ToolbarItemGroup(placement: .keyboard) { Button("Done") { focusedField = false } } } Text("test 2") .tabItem { Label("Home", systemImage: "house") } TextField("test 3", text: .constant("test 3")) .focused($focusedField) .tabItem { Label("tab 3", systemImage: "number") } .toolbar { ToolbarItemGroup(placement: .keyboard) { Button("Done") { focusedField = false } } } } .tint(.primary) } } @main struct MainApp: App { var body: some Scene { WindowGroup { MainTabView() } } }
1
0
436
Aug ’24
Hiding the NavigationSplitView's sidebar border.
I'm trying to build a custom designed sidebar for iPad that requires there to be no gray divider to separated the navigation and the detail view. I'm surprised at how unsuccessful I have been given how simple this is but have still found no luck. My current code: struct ContentView: View { var body: some View { NavigationSplitView { VStack { //code... } .background(.white) .navigationSplitViewColumnWidth(70) .navigationBarHidden(true) .edgesIgnoringSafeArea(.vertical) } detail: { //code... } } } I've attempted to add an overlay of a white rectangle to cover the divider but it just goes behind the existing border. I like to think there is a simpler solution anyways.
1
0
526
Aug ’24
Wrong unit in HIG > Components > System Experiences > Widget > watchOS widget dimensions
Hello, I noticed a small mistake in the Human Interface Guidelines (HIG). On the page HIG > Components > System Experiences > Widget > watchOS Widget Dimensions, scroll down to the bottom. In the "watchOS widget dimensions" section, the sizes in the table are in pixels (px), not points (pt) actually. However, the table header indicates the sizes should be in points (pt). Page link: https://developer.apple.com/design/human-interface-guidelines/widgets#watchOS-widget-dimensions For example, the widget size in the Smart Stack on a 49mm watch should be 192x81.5 pt (or 382x163 px), not 382x163 pt. This size can be verified with the information provided here: https://developer.apple.com/documentation/watchos-apps/supporting-multiple-watch-sizes/. https://developer.apple.com/documentation/watchkit/wkinterfacedevice/1620974-screenscale
3
0
660
Aug ’24
App is too minimal?
So, I run a website about my high school football team, and I created an app that would send score updates to people, provide the schedule, region and local team records. You could log in to adjust whether you get notified every score, or every quarter, or neither. However, when I uploaded it to Apple, it was rejected for it being too minimal. I mean, it does what people would want it to do, which if they can't make it to the game they'll get notified on score updates, the schedule, etc. I don't know what features to add to make it "less minimal". Any suggestions? Also, idk what tags to use for this so, I apologize if I put it in the wrong place.
2
0
552
Sep ’24
Button with symbol SF design like Apple
Hello everyone, I'm working on a fun project for my teacher and want to give my software an Apple-inspired look. Specifically, I'm trying to create image buttons similar to Apple's design (as shown in the image). I need a button with an image that darkens its background when the user hovers over it with the mouse. Any suggestions on how to achieve this effect would be greatly appreciated. For now, I have this code : import SwiftUI struct StudentRow: View { @Environment(\.modelContext) private var modelContext var student: Student @State private var isHover = false var body: some View { HStack { Text(student.name) Image(systemName: "xmark") .opacity(isHover ? 0.9 : 0.1) .bold() .onTapGesture { deleteStudent(student, modelContext: modelContext) } .onHover { hovering in isHover = hovering } } .padding() } } However, I'm not entirely satisfied with the outcome of this code. (Trust me, the outcome is the same when using the magnifying glass icon) plz help
1
0
575
Sep ’24
iPadOS 18 - Move Tab Bar to bottom
As iPadOS 18 shows Tab Bar on top (tvOS'esq), can someone please tell me what changes do I need to make to get tab bar shown as a regular one (Pre iPadOS 18 style)? Tab bar being at the bottom is easily accessible. And, it being on top needs too much of hands movement. That being on top is is occupying, in a way, more screen real estate. Any ideas appreciated. Thank you.
5
4
3.1k
Sep ’24
PLEASE READ - Easy App Ideas
As a beginner to Swift and SwiftUI, I would like to make a collaborative list on the Dev Forum of simple apps for beginners to develop which they could actually use. If you see this post, please reply with any easy app idea you can think of. Thank youuuuu :DDDD
1
0
371
Sep ’24
Apps cannot be on multiple screens in iOS 18
Since using the iOS 18 beta in July I am unable to add apps to multiple screens at a time. For example, I have a screen for my work focus and I cannot add the calculator app to this screen while it is on another screen. If I try to add it to a screen it is removed from the other screen. Has anyone else noticed this? Is this expected to be fixed in iOS 18 or could it be a retrogressive feature?
0
0
433
Sep ’24
MFMessageComposeViewController, SwiftUI, with attachment
My app needs to send iMessages with an attached data file. The view comes up modally and the user needs to press the send button. When the button is tapped the error occurs and the attachment and message is not delivered. I have tried three implementations of UIViewControllerRepresentable for MFMessageComposeViewController that have worked for iOS 15 and 16, but not 17. If I make the simplest app to show the problem, it will reliably fail on all iOS versions tested. If I remove the attachment, the message gets sent. In contrast, the equivalent UIViewControllerRepresentable for email works perfectly every time. After struggling for weeks to get it to work, I am beginning to believe this is a timing error in iOS. I have even tried unsuccessfully to include dispatch queue delays. Has anybody else written a swiftUI based app that can reliably attach a file to an iMessage send? UIViewControllerRepresentable: import SwiftUI import MessageUI import UniformTypeIdentifiers struct AttachmentData: Codable { var data:Data var mimeType:UTType var fileName:String } struct MessageView: UIViewControllerRepresentable { @Environment(\.presentationMode) var presentation @Binding var recipients:[String] @Binding var body: String @Binding var attachments:[AttachmentData] @Binding var result: Result<MessageComposeResult, Error>? func makeUIViewController(context: Context) -> MFMessageComposeViewController { let vc = MFMessageComposeViewController() print("canSendAttachments = \(MFMessageComposeViewController.canSendAttachments())") vc.recipients = recipients vc.body = body vc.messageComposeDelegate = context.coordinator for attachment in attachments { vc.addAttachmentData(attachment.data, typeIdentifier: attachment.mimeType.identifier, filename: attachment.fileName) } return vc } func updateUIViewController(_ uiViewController: MFMessageComposeViewController, context: Context) { } func makeCoordinator() -> Coordinator { return Coordinator(presentation: presentation, result: $result) } class Coordinator: NSObject, MFMessageComposeViewControllerDelegate { @Binding var presentation: PresentationMode @Binding var result: Result<MessageComposeResult, Error>? init(presentation: Binding<PresentationMode>, result: Binding<Result<MessageComposeResult, Error>?>) { _presentation = presentation _result = result } func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) { defer { $presentation.wrappedValue.dismiss() } switch result { case .cancelled: print("Message cancelled") self.result = .success(result) case .sent: print("Message sent") self.result = .success(result) case .failed: print("Failed to send") self.result = .success(result) @unknown default: fatalError() } } } } SwiftUI interface: import SwiftUI import MessageUI struct ContentView: View { @State private var isShowingMessages = false @State private var recipients = ["4085551212"] @State private var message = "Hello from California" @State private var attachment = [AttachmentData(data: Data("it is not zip format, however iMessage won't allow the recipient to open it if extension is not a well-known extension, like .zip".utf8), mimeType: .zip, fileName: "test1.zip")] @State var result: Result<MessageComposeResult, Error>? = nil var body: some View { VStack { Button { isShowingMessages.toggle() } label: { Text("Show Messages") } .sheet(isPresented: $isShowingMessages) { MessageView(recipients: $recipients, body: $message, attachments: $attachment, result: $result) } .onChange(of: isShowingMessages) { newValue in if !isShowingMessages { switch result { case .success(let type): switch type { case .cancelled: print("canceled") break case .sent: print("sent") default: break } default: break } } } } } } #Preview { ContentView() }
1
1
513
Sep ’24
Why are normal version iterations consistently rejected
After successfully passing the review for version 1.0, I was consistently rejected after updating to version 1.0.1 with 4.3 (a). However, I only added some paid products to the original features, and did not make any changes to the layout or UI design. Why do you keep rejecting me. Multiline BlockQuote hello, Thank you for your message. Regarding Guideline 4.3(a), we continue to notice that your app shares a similar binary, metadata, and/or concept as apps submitted to the App Store by other developers, with only minor differences. Some factors that contribute to a spam rejection may include: Submitting an app with the same source code or assets as other apps already submitted to the App Store Creating and submitting multiple similar apps using a repackaged app template Purchasing an app template with problematic code from a third party Submitting several similar apps across multiple accounts We hope that you will make the appropriate changes to your app to bring it into compliance with the App Store Review Guidelines and resubmit your app for review. Best regards,
3
0
410
Sep ’24
Lag When Dismissing Keyboard in ScrollView Inside NavigationStack in SwiftUI
I’m experiencing a lag in SwiftUI when dismissing the keyboard inside a ScrollView that’s within a NavigationStack. When the keyboard is opened and then dismissed, the view seems to lag as it resizes back to its original state. This issue occurs when the content is in a ScrollView. I’m using iOS 17, and the resizing of the content feels choppy after the keyboard interaction. Here’s a simplified version of my code: VStack { NavigationStack { ScrollView { createAllForm } .onAppear { if #available(iOS 17.0, *) { Self.addTripOpen.sendDonation() } } .toolbar { ToolbarItem(placement: .topBarLeading) { Button(action: { presentationMode.wrappedValue.dismiss() }, label: { Image(systemName: IconsEnum.closeIcon).foregroundColor(.gray) }) } } .toolbar { ToolbarItem(placement: .topBarTrailing) { Button(LocalizedText.create, action: { focusedField = nil withAnimation { addTripViewModel.creatingTrip = true addTripViewModel.addTripToFirebase(presentationMode: presentationMode) } }).disabled(addTripViewModel.disableCreate).foregroundColor(Color(addTripViewModel.disableCreate ? ColorsEnum.greyColor : ColorsEnum.tripBlue)) } } .navigationTitle(LocalizedText.createTrip) .navigationBarTitleDisplayMode(.inline) .isLoadingView(isLoading: addTripViewModel.creatingTrip) .alert(addTripViewModel.alertMessage, isPresented: $addTripViewModel.showingAlert) { Button(LocalizedText.acceptLabel, role: .cancel) { } } .onDisappear { if addTripViewModel.isCreated { processCompletedCount += 1 } if let currentAppVersion = Bundle.currentAppVersion, processCompletedCount >= 2, currentAppVersion != lastVersionPromptedForReview, addTripViewModel.isCreated { presentReview() lastVersionPromptedForReview = currentAppVersion } onDismiss(addTripViewModel.isCreated) } .sheet(isPresented: $addTripViewModel.showingAddUsers) { AddUsers().environmentObject(addTripViewModel) } } }
2
0
338
Sep ’24