Post

Replies

Boosts

Views

Activity

Reply to Xcode Missing checkbox "Support Multiple Windows"
Click on the little arrow next to "Supports multiple windows", or go to the "Info" tab, and you will see a small property list table Expand the row that says "Application Scene Manifest" Inside you will see the key "Enable Multiple Windows" Set the value for this to YES (the default) If any of these keys are not there, you will have to add them yourself. I don't know if the checkbox was removed intentionally or not, but it does seem a little strange.
Topic: UI Frameworks SubTopic: UIKit Tags:
Nov ’22
Reply to No replacement for MKMaptype globe view in iOS16?
There are three subclasses of MKMapConfiguration: MKStandardMapConfiguration MKHybridMapConfiguration MKImageryMapConfiguration Here are some example conversions from MKMapType to MKMapConfiguration: // MKMapType.standard MKStandardMapConfiguration(elevationStyle: .flat) // MKMapType.satellite MKImageryMapConfiguration(elevationStyle: .flat) // MKMapType.hybrid MKHybridMapConfiguration(elevationStyle: .flat) // MKMapType.satelliteFlyover MKImageryMapConfiguration(elevationStyle: .realistic) // MKMapType.hybridFlyover MKHybridMapConfiguration(elevationStyle: .realistic) // MKMapType.mutedStandard MKStandardMapConfiguration(emphasisStyle: .muted)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
Reply to Display fetched data in SwiftUI
You're kind of mixing up two approaches here: completion handlers and return values, like seen with async/await. Since your data fetch is using a completion handler, you can follow this route and add a completion closure parameter to the getData function which can then be called when you get the data. Here's an example of what this would look like: private func getData(from url: String, completion: @escaping (Response) -> Void) {     let task = URLSession.shared.dataTask(with: URL(string: url)!) { data, response, error in         ... completion(json)     }     task.resume() } // in SwiftUI View .onAppear { getData(from: url) { results = $0 } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
Reply to navigate to another view Swiftui
You can use a special type of button that is specifically for navigation called NavigationLink. Use it like this: NavigationLink { // destination view to navigation to DetailView() } label: { Image(systemName: "list.dash")      .foregroundColor(.gray) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
Reply to How to sort birthdays in swiftUI so that next birthday from today is on top of the list?
I have just created a playground to test this code out. It seems to work properly for the dates I have provided. See what you think and whether it works in your project. let calendar = Calendar.current // Manual creation of dates so you can see what the values for each are let components = [     DateComponents(year: 2004, month: 3, day: 26),     DateComponents(year: 1973, month: 7, day: 4),     DateComponents(year: 1992, month: 4, day: 1),     DateComponents(year: 2012, month: 12, day: 23),     DateComponents(year: 1988, month: 9, day: 16) ] let birthdays = components.compactMap(calendar.date) // You would only need this bit in your project let nextBirthdays = birthdays.compactMap {     let components = calendar.dateComponents([.day, .month], from: $0)     return calendar.nextDate(after: .now, matching: components, matchingPolicy: .nextTime) }.sorted(by: <) let nextBirthday = nextBirthdays.first print(nextBirthday) // Optional(2022-12-23 00:00:00 +0000) This part is what you would put in your project: // Wrap up next birthday calculation inside a function func nextBirthday(for birthday: Date) -> Date { let calendar = Calendar.current let components = calendar.dateComponents([.day, .month], from: birthday)     return calendar.nextDate(after: .now, matching: components, matchingPolicy: .nextTime) ?? .distantFuture } // Sorted friends by next birthday first friends.sorted { nextBirthday(for: $0.bday) < nextBirthday(for: $1.bday) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
Reply to How deploy Mac app on local computer
You can archive the app and have a copy that stored locally on your computer. In the menu bar, go to Product > Archive In the Archives window that opens, select the version you want and click Distribute App Select Copy App as the distribution method Choose a name and location then click Export Open the folder that you just created and double-click the app file inside to run it
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
Reply to Calculation for a Picker
What you need to do is create a computed variable that calculates the speed using the three picker values and your formula. Here's an example of what that would look like: struct ContentView: View {     @State var secondesSelection = 10     @State var dixiemesSelection = 0     @State var pisteSelection = 200     let secondes = Array(10..<60)     let dixiemes = Array(0..<10)     let longueurPiste = [200, 250, 333, 500] // Create computed variable that calculates the speed (in km/h)     var vitesseCalculee: Double {         let tempsTour = Double(secondesSelection) + (Double(dixiemesSelection) / 10)         return (Double(pisteSelection) / 1000) / (tempsTour / 3600)     } // Nicely format that speed (rounding to 3 s.f.)     var formattedVitesseCalculee: String {         "\(vitesseCalculee.formatted(.number.precision(.significantDigits(3)))) km/h"     }     var body: some View {         VStack {             Label("Calcul du temps au tour", systemImage: "stopwatch")             Spacer()             Text("Longueur de la piste")                 .font(.title.bold())                 .foregroundColor(.blue)             Picker("Longueur de la piste", selection: $pisteSelection) {                 ForEach(longueurPiste, id: \.self) {                     Text("\($0) m")                 }             }             .pickerStyle(.wheel)             Text("Temps au tour")                 .font(.title.bold())                 .foregroundColor(.blue)             HStack {                 Text("Secondes")                 Text("Dixièmes")             }             HStack {                 Picker("Secondes", selection: $secondesSelection) {                     ForEach(secondes, id: \.self) {                         Text("\($0)'")                     }                 }                 Picker("Dixièmes", selection: $dixiemesSelection) {                     ForEach(dixiemes, id: \.self) {                         Text("\($0)")                     }                 }             }             .pickerStyle(.wheel)             Spacer()             Text("Vitesse calculée: \(formattedVitesseCalculee)")                 .font(.largeTitle)                 .foregroundColor(.blue)         }     } } Your program had a few warnings when I pasted your code in so I resolved them.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
Reply to No exact matches in call to instance method 'scaleEffect' ?
Your issue seems to be caused by a typo on this line: @State private var ismageScale: CGFloat = 1 // typo ^^^^^^^^^^^ I'm assuming it should be imageScale like you have used everywhere else in your program. The error is not as helpful as it could be but it does show you there is something wrong with the call to scaleEffect(_:) – there is no variable named imageScale to use.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
Reply to How can I add a second row of buttons in my frame when my hstack is too long in Swift UI?
This kind of layout is a horizontal flow layout, because the rows flow on to the next when they run out of space horizontally. You could start by having a look online for some example code: I know there is one from Apple buried in a sample project. I would also recommend looking into the new Layout protocol introduced in iOS 16 which would help immensely and also make the layout reusable.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
Reply to Xcode Missing checkbox "Support Multiple Windows"
Click on the little arrow next to "Supports multiple windows", or go to the "Info" tab, and you will see a small property list table Expand the row that says "Application Scene Manifest" Inside you will see the key "Enable Multiple Windows" Set the value for this to YES (the default) If any of these keys are not there, you will have to add them yourself. I don't know if the checkbox was removed intentionally or not, but it does seem a little strange.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to SwiftUI List on maCOS: highlighting content in the selected row?
There is a modifier called listItemTint(_:) that seems like it should do what you are asking for. It's worth checking out, but I believe the behaviour changed in iOS 15 for some reason, intentionally or not.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to No replacement for MKMaptype globe view in iOS16?
There are three subclasses of MKMapConfiguration: MKStandardMapConfiguration MKHybridMapConfiguration MKImageryMapConfiguration Here are some example conversions from MKMapType to MKMapConfiguration: // MKMapType.standard MKStandardMapConfiguration(elevationStyle: .flat) // MKMapType.satellite MKImageryMapConfiguration(elevationStyle: .flat) // MKMapType.hybrid MKHybridMapConfiguration(elevationStyle: .flat) // MKMapType.satelliteFlyover MKImageryMapConfiguration(elevationStyle: .realistic) // MKMapType.hybridFlyover MKHybridMapConfiguration(elevationStyle: .realistic) // MKMapType.mutedStandard MKStandardMapConfiguration(emphasisStyle: .muted)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to Display fetched data in SwiftUI
You're kind of mixing up two approaches here: completion handlers and return values, like seen with async/await. Since your data fetch is using a completion handler, you can follow this route and add a completion closure parameter to the getData function which can then be called when you get the data. Here's an example of what this would look like: private func getData(from url: String, completion: @escaping (Response) -> Void) {     let task = URLSession.shared.dataTask(with: URL(string: url)!) { data, response, error in         ... completion(json)     }     task.resume() } // in SwiftUI View .onAppear { getData(from: url) { results = $0 } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to How to dismiss a Sheet and open a NavigationLink in a new View?
You have already posted this question here to which I have provided a possible solution.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to navigate to another view Swiftui
You can use a special type of button that is specifically for navigation called NavigationLink. Use it like this: NavigationLink { // destination view to navigation to DetailView() } label: { Image(systemName: "list.dash")      .foregroundColor(.gray) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to How to sort birthdays in swiftUI so that next birthday from today is on top of the list?
I have just created a playground to test this code out. It seems to work properly for the dates I have provided. See what you think and whether it works in your project. let calendar = Calendar.current // Manual creation of dates so you can see what the values for each are let components = [     DateComponents(year: 2004, month: 3, day: 26),     DateComponents(year: 1973, month: 7, day: 4),     DateComponents(year: 1992, month: 4, day: 1),     DateComponents(year: 2012, month: 12, day: 23),     DateComponents(year: 1988, month: 9, day: 16) ] let birthdays = components.compactMap(calendar.date) // You would only need this bit in your project let nextBirthdays = birthdays.compactMap {     let components = calendar.dateComponents([.day, .month], from: $0)     return calendar.nextDate(after: .now, matching: components, matchingPolicy: .nextTime) }.sorted(by: <) let nextBirthday = nextBirthdays.first print(nextBirthday) // Optional(2022-12-23 00:00:00 +0000) This part is what you would put in your project: // Wrap up next birthday calculation inside a function func nextBirthday(for birthday: Date) -> Date { let calendar = Calendar.current let components = calendar.dateComponents([.day, .month], from: birthday)     return calendar.nextDate(after: .now, matching: components, matchingPolicy: .nextTime) ?? .distantFuture } // Sorted friends by next birthday first friends.sorted { nextBirthday(for: $0.bday) < nextBirthday(for: $1.bday) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to How deploy Mac app on local computer
You can archive the app and have a copy that stored locally on your computer. In the menu bar, go to Product > Archive In the Archives window that opens, select the version you want and click Distribute App Select Copy App as the distribution method Choose a name and location then click Export Open the folder that you just created and double-click the app file inside to run it
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to SwiftUI Image has no member 'resizable'
It seems like Image is being interpreted as a UIImage instead of a SwiftUI.Image. Maybe you have something like this in your code: typealias Image = UIImage
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to SwiftUI Picker doesn't use NavigationView
I believe in iOS 16.1 this feature was put back in SwiftUI, but in the form of a new picker style (since the default is .menu). It's called .navigationLink and is available from iOS 16.0.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to how i make List with storyboard?
If I'm understanding what you're saying, you need to set the UITableView style to .insetGrouped.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to Calculation for a Picker
What you need to do is create a computed variable that calculates the speed using the three picker values and your formula. Here's an example of what that would look like: struct ContentView: View {     @State var secondesSelection = 10     @State var dixiemesSelection = 0     @State var pisteSelection = 200     let secondes = Array(10..<60)     let dixiemes = Array(0..<10)     let longueurPiste = [200, 250, 333, 500] // Create computed variable that calculates the speed (in km/h)     var vitesseCalculee: Double {         let tempsTour = Double(secondesSelection) + (Double(dixiemesSelection) / 10)         return (Double(pisteSelection) / 1000) / (tempsTour / 3600)     } // Nicely format that speed (rounding to 3 s.f.)     var formattedVitesseCalculee: String {         "\(vitesseCalculee.formatted(.number.precision(.significantDigits(3)))) km/h"     }     var body: some View {         VStack {             Label("Calcul du temps au tour", systemImage: "stopwatch")             Spacer()             Text("Longueur de la piste")                 .font(.title.bold())                 .foregroundColor(.blue)             Picker("Longueur de la piste", selection: $pisteSelection) {                 ForEach(longueurPiste, id: \.self) {                     Text("\($0) m")                 }             }             .pickerStyle(.wheel)             Text("Temps au tour")                 .font(.title.bold())                 .foregroundColor(.blue)             HStack {                 Text("Secondes")                 Text("Dixièmes")             }             HStack {                 Picker("Secondes", selection: $secondesSelection) {                     ForEach(secondes, id: \.self) {                         Text("\($0)'")                     }                 }                 Picker("Dixièmes", selection: $dixiemesSelection) {                     ForEach(dixiemes, id: \.self) {                         Text("\($0)")                     }                 }             }             .pickerStyle(.wheel)             Spacer()             Text("Vitesse calculée: \(formattedVitesseCalculee)")                 .font(.largeTitle)                 .foregroundColor(.blue)         }     } } Your program had a few warnings when I pasted your code in so I resolved them.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to No exact matches in call to instance method 'scaleEffect' ?
Your issue seems to be caused by a typo on this line: @State private var ismageScale: CGFloat = 1 // typo ^^^^^^^^^^^ I'm assuming it should be imageScale like you have used everywhere else in your program. The error is not as helpful as it could be but it does show you there is something wrong with the call to scaleEffect(_:) – there is no variable named imageScale to use.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to How can I add a second row of buttons in my frame when my hstack is too long in Swift UI?
This kind of layout is a horizontal flow layout, because the rows flow on to the next when they run out of space horizontally. You could start by having a look online for some example code: I know there is one from Apple buried in a sample project. I would also recommend looking into the new Layout protocol introduced in iOS 16 which would help immensely and also make the layout reusable.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to Navigation View inside Tabview not displaying correctly in landscape mode
This is the default behaviour for NavigationView – single column in a compact horizontal size class and a two/three column layout in a regular size class. Either apply this modifier to the NavigationView: navigationViewStyle(.stack) or use a NavigationStack instead.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22