Post

Replies

Boosts

Views

Activity

Reply to Regarding Battery Health of my iphone 14
These are the Developer Forums, where developers of apps for Apple's platforms ask each other for hints and tips on coding. These forums are NOT where Apple's actual developers chat about stuff. Your question is more of a product support one, so I'd suggest you ask it over at the Apple Support Forums. Thanks.
Topic: App & System Services SubTopic: Hardware Tags:
Jul ’24
Reply to IOS 18 BETA 2 HANGING PROBLEMS
Honestly, what on Earth do you think we can do with this information? Okay, your iPhone 12 "hangs". What do you mean by "hangs"? Have you raised a Feedback report? If not, please do so at https://www.apple.com/feedback/ then post the FB number here. If you've found an issue in the beta, raise it, don't grumble on here about it because we cannot do anything to help you. We're third-party developers. We aren't Apple employees.
Topic: UI Frameworks SubTopic: SwiftUI
Jul ’24
Reply to IOS 18 Beta issues
Please don't raise bugs in a new version of an OS in a post here on the Developer Forums. Apple's engineers aren't reading through these pages to see if anyone's found a bug. These forums are for third-party developers writing apps for Apple's platforms to discuss issues with their code. You need to raise each individual issue separately at https://www.apple.com/feedback/ You can post the FB numbers here if you want, so that others can link to them.
Jul ’24
Reply to Stop saving airdrop files in iCloud
Why can't you choose the destination? What files and file types are you receiving? What used to happen? What happens now? Does it happen to all file types? If you're going to report an issue, don't you think you should provide the minimum info for us? We can't help you if you don't give us the relevant information.
Jul ’24
Reply to Attempt to present * on * from * while a presentation is in progress
A few things here: You don't need to write this: let months = [1,2,3,4,5,6,7,8,9,10,11,12] You can use: let months = [1...12] But, you only use this once, so instead of this: ForEach (months, id: \.self) { month in you can use this: ForEach(1...12, id: \.self) { month in Secondly, when you write switch month { case 01: ... You've declared month as an Int, and you don't need to use leading zeroes, so you should write: switch month { case 1: ... BUT... There's a much simpler way of doing this. Look into DateFormatter() with a format of MMM. Something like: func getMonthText(_ month: Int) -> String { let dateFormatter = DateFormatter() dateFormatter.locale = Locale(identifier: "en_US") dateFormatter.dateFormat = "MM" let firstOfMonth = dateFormatter.date(from: "\(month)")! dateFormatter.dateFormat = "MMM" return dateFormatter.string(from: firstOfMonth) } The issue you're having with presenting is because you've put the sheet inside the ForEach loop. You're only showing the sheet once when one thing is tapped, so you can just add it anywhere in the View. This works: import SwiftUI struct ContentView: View { @State private var selectedMonth = 1 @State private var selectedYear = "2024" @State private var isShowing = false var body: some View { List { ForEach(1...12, id: \.self) { month in HStack { ViewList(month: month, year: selectedYear) .onTapGesture { isShowing = true selectedMonth = month } } } } .listRowSpacing(2) .listStyle(.grouped) // MOVED THIS TO HERE .sheet(isPresented: $isShowing){ PopupView(month: selectedMonth, year: selectedYear) .presentationDetents([.large]) } } } struct ViewList: View { var month: Int var year: String var body: some View { VStack(alignment: .leading) { Text("\(getMonthText(month)) / \(year)") .font(.headline) } } } struct PopupView: View { @Environment(\.dismiss) var dismiss var month: Int var year: String @State private var selectedMonthText = "Jan" @State private var imageText = "plus" @State private var items = ["Cat", "Dog", "Bird", "Snake"] var body: some View { Button("Dismiss") { dismiss() } Text("\(selectedMonthText) / \(year)") List { ForEach(items, id: \.self) {item in HStack { Text(item) Text("Fed on: ") Text(selectedMonthText) } } } .listRowSpacing(0) .listStyle(.inset) .onAppear { selectedMonthText = getMonthText(month) } } } func getMonthText(_ month: Int) -> String { let dateFormatter = DateFormatter() dateFormatter.locale = Locale(identifier: "en_US") dateFormatter.dateFormat = "MM" let firstOfMonth = dateFormatter.date(from: "\(month)")! dateFormatter.dateFormat = "MMM" return dateFormatter.string(from: firstOfMonth) } #Preview { ContentView() }
Topic: Community SubTopic: Apple Developers Tags:
Jul ’24