Post

Replies

Boosts

Views

Activity

Reply to Image & Text inside picker.
If you use directly Image, it does not work. You have to use the Image built from a resized UIImage. That would be worth a bug report. Get a solution here: https://www.hackingwithswift.com/forums/swift/remove-or-resize-an-image-when-selecting-an-item-in-a-picker-view/23940 Here is the full code. Fiat 500e is an image in Assets struct ContentView: View { struct Data: Identifiable, Hashable { var id = UUID() var name: String var condition: Bool } @State var selection = "Easy" var datas: [Data] = [Data(name: "Easy", condition: true), Data(name: "Medium", condition: false), Data(name: "Hard", condition: true)] var myImage: UIImage = UIImage(named: "Fiat 500e") ?? UIImage() var resizedImage: UIImage { return myImage.scalePreservingAspectRatio(targetSize: CGSize(width: 50, height: 25)) } var body: some View { Picker("Title: ", selection: $selection) { ForEach(datas, id: \.self) { data in HStack { Text(data.name) if data.condition { Image(systemName: "globe") } else { Image(uiImage: resizedImage) .resizable() .scaledToFit() } } .tag(data.name) .padding() } } } } extension UIImage { func scalePreservingAspectRatio(targetSize: CGSize) -> UIImage { // Determine the scale factor that preserves aspect ratio let widthRatio = targetSize.width / size.width let heightRatio = targetSize.height / size.height let scaleFactor = min(widthRatio, heightRatio) // Compute the new image size that preserves aspect ratio let scaledImageSize = CGSize( width: size.width * scaleFactor, height: size.height * scaleFactor ) // Draw and return the resized UIImage let renderer = UIGraphicsImageRenderer( size: scaledImageSize ) let scaledImage = renderer.image { _ in self.draw(in: CGRect( origin: .zero, size: scaledImageSize )) } return scaledImage } } The image displayed in selection is now resized (it was automatically resized in Picker): In Picker. After selection.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’25
Reply to Plagiarism
Very nice. How do you use it in your app ? But effectively, I would not do it, it is too close to Apple's design and could be considered as some try to lure people into believing your app is an Apple app.
Topic: Design SubTopic: General Tags:
Feb ’25
Reply to Judge Time About Swift Student Challenge
It cannot be eliminatory, as it is not a video but depends on how the reviewer tests your app. So, as far as I understand, it is more a (strong) guideline than a requirement. My understanding is that reviewer have a limited time and may stop the test after 3 minutes. So that's you to decide to take the risk or not. But take care, it must be possible to appreciate your app in 3 minutes, even if not completely explored.
Feb ’25
Reply to Hello.
Welcome to the forum. This forum is for developers who need help or advice for developing their apps. It is not about software use, unless they are development tools. And it is not an official channel to Apple. You'd better post on the Apple Support Community: https://discussions.apple.com/welcome, or file a bug report. https://feedbackassistant.apple.com
Feb ’25
Reply to Swiftui Charts
Very strange indeed. I've tried using RuleMark as explained here: https://stackoverflow.com/questions/78873602/reverse-y-axis-of-swiftui-chart But get the same flipping. It does not occur if all values are equal but non zero: let data: [Double] = [10, 10, 10, 10, 10] Looks like a side effect of a "zero divide" (between the default minimum zero of y axis and the found max which is also 0) : when all values are equal, it wrongly computes the orientation (as you will see, chartYScale corrects this by providing the orientation). You should file a bug report. I found a solution using chartYScale: struct ChartView: View { let data: [Double] = [0, 0, 0, 0, 0] var body: some View { Chart { ForEach(data.indices, id: \.self) { index in LineMark( x: .value("Index", index), y: .value("Value", data[index]) ) } } .chartYScale(domain: [0, 50]) // <<-- Added this .chartYAxis { AxisMarks(values: [0, 10, 20, 30, 40, 50]) { value in AxisValueLabel() AxisTick() AxisGridLine() } } .padding() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’25
Reply to They reject my version because of a Terms of Use link that they ask me to add and this has existed since several versions ago
I requested that they approve my version to solve other details I do doubt they will even consider it. You have to comply first, then they may approve. Did you explain (in the comments to reviewer) why you think you comply ? That's the best way to get your voice heard.
Replies
Boosts
Views
Activity
Feb ’25
Reply to Image & Text inside picker.
If you use directly Image, it does not work. You have to use the Image built from a resized UIImage. That would be worth a bug report. Get a solution here: https://www.hackingwithswift.com/forums/swift/remove-or-resize-an-image-when-selecting-an-item-in-a-picker-view/23940 Here is the full code. Fiat 500e is an image in Assets struct ContentView: View { struct Data: Identifiable, Hashable { var id = UUID() var name: String var condition: Bool } @State var selection = "Easy" var datas: [Data] = [Data(name: "Easy", condition: true), Data(name: "Medium", condition: false), Data(name: "Hard", condition: true)] var myImage: UIImage = UIImage(named: "Fiat 500e") ?? UIImage() var resizedImage: UIImage { return myImage.scalePreservingAspectRatio(targetSize: CGSize(width: 50, height: 25)) } var body: some View { Picker("Title: ", selection: $selection) { ForEach(datas, id: \.self) { data in HStack { Text(data.name) if data.condition { Image(systemName: "globe") } else { Image(uiImage: resizedImage) .resizable() .scaledToFit() } } .tag(data.name) .padding() } } } } extension UIImage { func scalePreservingAspectRatio(targetSize: CGSize) -> UIImage { // Determine the scale factor that preserves aspect ratio let widthRatio = targetSize.width / size.width let heightRatio = targetSize.height / size.height let scaleFactor = min(widthRatio, heightRatio) // Compute the new image size that preserves aspect ratio let scaledImageSize = CGSize( width: size.width * scaleFactor, height: size.height * scaleFactor ) // Draw and return the resized UIImage let renderer = UIGraphicsImageRenderer( size: scaledImageSize ) let scaledImage = renderer.image { _ in self.draw(in: CGRect( origin: .zero, size: scaledImageSize )) } return scaledImage } } The image displayed in selection is now resized (it was automatically resized in Picker): In Picker. After selection.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’25
Reply to stuck with out-of-date version of the application
That's for the version, but have you checked the build number ? What is the build number of each version ? Build number must always be higher (alphabetical order) than the previous version. Note also that this forum is not the best place to contact Apple. You'd better directly contact support: https://developer.apple.com/contact/topic/select
Replies
Boosts
Views
Activity
Feb ’25
Reply to Plagiarism
Very nice. How do you use it in your app ? But effectively, I would not do it, it is too close to Apple's design and could be considered as some try to lure people into believing your app is an Apple app.
Topic: Design SubTopic: General Tags:
Replies
Boosts
Views
Activity
Feb ’25
Reply to Judge Time About Swift Student Challenge
It cannot be eliminatory, as it is not a video but depends on how the reviewer tests your app. So, as far as I understand, it is more a (strong) guideline than a requirement. My understanding is that reviewer have a limited time and may stop the test after 3 minutes. So that's you to decide to take the risk or not. But take care, it must be possible to appreciate your app in 3 minutes, even if not completely explored.
Replies
Boosts
Views
Activity
Feb ’25
Reply to Hello.
Welcome to the forum. This forum is for developers who need help or advice for developing their apps. It is not about software use, unless they are development tools. And it is not an official channel to Apple. You'd better post on the Apple Support Community: https://discussions.apple.com/welcome, or file a bug report. https://feedbackassistant.apple.com
Replies
Boosts
Views
Activity
Feb ’25
Reply to Swiftui Charts
Very strange indeed. I've tried using RuleMark as explained here: https://stackoverflow.com/questions/78873602/reverse-y-axis-of-swiftui-chart But get the same flipping. It does not occur if all values are equal but non zero: let data: [Double] = [10, 10, 10, 10, 10] Looks like a side effect of a "zero divide" (between the default minimum zero of y axis and the found max which is also 0) : when all values are equal, it wrongly computes the orientation (as you will see, chartYScale corrects this by providing the orientation). You should file a bug report. I found a solution using chartYScale: struct ChartView: View { let data: [Double] = [0, 0, 0, 0, 0] var body: some View { Chart { ForEach(data.indices, id: \.self) { index in LineMark( x: .value("Index", index), y: .value("Value", data[index]) ) } } .chartYScale(domain: [0, 50]) // <<-- Added this .chartYAxis { AxisMarks(values: [0, 10, 20, 30, 40, 50]) { value in AxisValueLabel() AxisTick() AxisGridLine() } } .padding() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’25