Another view could be presented as a sheet.
You can also specify how the sheet is displayed by configuring presentationDetents.
fullScreenCover would also be an option for displaying a view.
Post
Replies
Boosts
Views
Activity
If you have a content and a detail, the content probably is a list, which stores the selected value via the 'selection' parameter. That value goes into the detail view. On the Apple website is an example.
@State private var categories: [String] = []
@State private var selectedCategory: String?
List(
categories,
selection: $selectedCategory
) { category in
NavigationLink(category.name, value: category)
}
.navigationTitle("Categories")
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
A NavigationStack with NavigationLink is a good choice if you would like to navigate to a different view.
But it depends on what exactly you would like to do.
A NavigationSplitView could also be an option.
Have you already prepared something that you can post here?
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Hi Pokpong,
I was not notified about your response.
I waited for the data to load, and then deleted it, but the error is still there. The error still occurs even if recipes.removeAll() remains in place.
Apple responded after just one day, stating that they were unable to reproduce the issue using my project. They then asked me for a video demonstrating the error. After I sent the video, I heard nothing further from them.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Okay, I understand. Then I'll stick with 1.3GB for now. (-:
Topic:
App & System Services
SubTopic:
Core OS
Tags:
Bug report number is FB25245021
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
My first attempt using the ID didn't work, and the data continued to be displayed incorrectly.
I’m not entirely sure what went wrong, so I tried again today.
With the unique ID, the data was displayed correctly.
This can be achieved either by implementing the Identifiable protocol or by using the chart initializer that accepts both data and an ID.
struct MonthlyHoursOfSunshine: Identifiable {
var city: String
var date: Date
var hoursOfSunshine: Double
var monthlyId: UUID = UUID()
init(city: String, month: Int, hoursOfSunshine: Double) {
let calendar = Calendar.autoupdatingCurrent
self.city = city
self.date = calendar.date(from: DateComponents(year: 2020, month: month))!
self.hoursOfSunshine = hoursOfSunshine
}
var id: UUID {
monthlyId
}
}
However, as I mentioned earlier, the Apple example I initially used as a reference is now flawed; the data neither implements Identifiable nor uses the initializer that includes an ID.
Christian
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Hi,
as I already mentioned in my first post—including a link to the Apple website—the example is not my own code; it comes from Apple itself.
The example worked prior to version 27, which is why I formatted my data in exactly that way; it ran without any issues until version 27.
I have already structured my data differently, though I might adjust it again.
For now, however, I am occupied with other SwiftUI bugs—for instance, NavigationSplitView, endless loop detail<->content
Unfortunately, no one has responded to the post yet.
I wanted to wait for a response before submitting a bug report, in case the procedure I’m following is incorrect.
Christian
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Hi Claude,
thank you for your answer.
I have incorporated your bug report into my example and updated my repository.
I reported a bug that someone else had already found—more than ten years before me. So, I don't have much hope that anything will happen there in the near future.
I’ve also documented a few other bugs on my GitHub.
Christian
Topic:
Media Technologies
SubTopic:
Audio
Tags:
Hello Travis,
thank you for your answer.
I chose this approach because I wanted to minimize the effort involved in switching to NavigationSplitView.
I had assumed that the content and detail views would be set automatically thanks to NavigationLink and navigationDestination. However, I haven't found any examples that follow the pattern I used.
I was just wondering why the detail area is mandatory, even if it’s empty.
I infer that my approach isn't quite right from the behavior I'm seeing.
I had already implemented your placeholder suggestion, and it indicates that something is wrong: the placeholder only appears once. When I switch categories, the placeholder doesn't show up; instead, a warning triangle appears.
I’ve watched the video several times and also downloaded and carefully examined the accompanying source code.
I also noticed today that the link to "Bringing robust navigation structure to your SwiftUI app" has been changed, as the old link no longer works.
The link points to .../swiftui/bringing_robust_navigation_structure_to_your_swiftui_app, but the correct link is .../swiftui/bringing-robust-navigation-structure-to-your-swiftui-app.
Underscores were replaced with hyphens.
I might just stick with the two-column solution.
Christian
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
As is often the case, a boolean field helps.
@State private var flagField1: Bool = false
.task(id: field1) {
if flagField1 == false {
flagField1 = true
return
}
print("task 1")
}
As previously mentioned, onChange has a parameter called initial. That is handled better there.
Christian
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
The bug report number is FB25051093
Christian
Topic:
Media Technologies
SubTopic:
Audio
Tags:
Hi,
thanks for the tip about the bug report. I thought the forum was also for reporting bugs.
The Bug Report number is FB25050954
Christian
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
This works
var dataMultiLine: [LocationData.Series] {
LocationData.last30Days
}
struct MultiLineView: View {
var body: some View {
VStack {
Chart {
ForEach(dataMultiLine) { series in
ForEach(series.sales, id: \.day) { element in
LineMark(
x: .value("Day", element.day, unit: .day),
y: .value("Sales", element.sales)
)
}
.foregroundStyle(by: .value("City", series.city))
.symbol(by: .value("City", series.city))
.interpolationMethod(.catmullRom)
}
}
}
.padding()
}
}
This doesn't work
var dataContent: [MonthlyHoursOfSunshine] = [
MonthlyHoursOfSunshine(city: "Cupertino", month: 1, hoursOfSunshine: 196),
MonthlyHoursOfSunshine(city: "Seattle", month: 1, hoursOfSunshine: 74),
MonthlyHoursOfSunshine(city: "Seattle", month: 12, hoursOfSunshine: 62),
MonthlyHoursOfSunshine(city: "Cupertino", month: 12, hoursOfSunshine: 199),
]
struct ContentView: View {
var body: some View {
VStack {
Chart(dataContent) {
LineMark(
x: .value("Month", $0.date),
y: .value("Hours of Sunshine", $0.hoursOfSunshine)
)
.foregroundStyle(by: .value("City", $0.city))
.symbol(by: .value("City", $0.city))
}
}
.padding()
}
}
Christian
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
When will there be a bug fix?
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Another view could be presented as a sheet.
You can also specify how the sheet is displayed by configuring presentationDetents.
fullScreenCover would also be an option for displaying a view.
- Replies
- Boosts
- Views
- Activity
If you have a content and a detail, the content probably is a list, which stores the selected value via the 'selection' parameter. That value goes into the detail view. On the Apple website is an example.
@State private var categories: [String] = []
@State private var selectedCategory: String?
List(
categories,
selection: $selectedCategory
) { category in
NavigationLink(category.name, value: category)
}
.navigationTitle("Categories")
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
- Replies
- Boosts
- Views
- Activity
A NavigationStack with NavigationLink is a good choice if you would like to navigate to a different view.
But it depends on what exactly you would like to do.
A NavigationSplitView could also be an option.
Have you already prepared something that you can post here?
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
- Replies
- Boosts
- Views
- Activity
Hi Pokpong,
I was not notified about your response.
I waited for the data to load, and then deleted it, but the error is still there. The error still occurs even if recipes.removeAll() remains in place.
Apple responded after just one day, stating that they were unable to reproduce the issue using my project. They then asked me for a video demonstrating the error. After I sent the video, I heard nothing further from them.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
- Replies
- Boosts
- Views
- Activity
Okay, I understand. Then I'll stick with 1.3GB for now. (-:
Topic:
App & System Services
SubTopic:
Core OS
Tags:
- Replies
- Boosts
- Views
- Activity
Bug report number is FB25245021
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
- Replies
- Boosts
- Views
- Activity
My first attempt using the ID didn't work, and the data continued to be displayed incorrectly.
I’m not entirely sure what went wrong, so I tried again today.
With the unique ID, the data was displayed correctly.
This can be achieved either by implementing the Identifiable protocol or by using the chart initializer that accepts both data and an ID.
struct MonthlyHoursOfSunshine: Identifiable {
var city: String
var date: Date
var hoursOfSunshine: Double
var monthlyId: UUID = UUID()
init(city: String, month: Int, hoursOfSunshine: Double) {
let calendar = Calendar.autoupdatingCurrent
self.city = city
self.date = calendar.date(from: DateComponents(year: 2020, month: month))!
self.hoursOfSunshine = hoursOfSunshine
}
var id: UUID {
monthlyId
}
}
However, as I mentioned earlier, the Apple example I initially used as a reference is now flawed; the data neither implements Identifiable nor uses the initializer that includes an ID.
Christian
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
- Replies
- Boosts
- Views
- Activity
Hi,
as I already mentioned in my first post—including a link to the Apple website—the example is not my own code; it comes from Apple itself.
The example worked prior to version 27, which is why I formatted my data in exactly that way; it ran without any issues until version 27.
I have already structured my data differently, though I might adjust it again.
For now, however, I am occupied with other SwiftUI bugs—for instance, NavigationSplitView, endless loop detail<->content
Unfortunately, no one has responded to the post yet.
I wanted to wait for a response before submitting a bug report, in case the procedure I’m following is incorrect.
Christian
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
- Replies
- Boosts
- Views
- Activity
Hi Claude,
thank you for your answer.
I have incorporated your bug report into my example and updated my repository.
I reported a bug that someone else had already found—more than ten years before me. So, I don't have much hope that anything will happen there in the near future.
I’ve also documented a few other bugs on my GitHub.
Christian
Topic:
Media Technologies
SubTopic:
Audio
Tags:
- Replies
- Boosts
- Views
- Activity
Hello Travis,
thank you for your answer.
I chose this approach because I wanted to minimize the effort involved in switching to NavigationSplitView.
I had assumed that the content and detail views would be set automatically thanks to NavigationLink and navigationDestination. However, I haven't found any examples that follow the pattern I used.
I was just wondering why the detail area is mandatory, even if it’s empty.
I infer that my approach isn't quite right from the behavior I'm seeing.
I had already implemented your placeholder suggestion, and it indicates that something is wrong: the placeholder only appears once. When I switch categories, the placeholder doesn't show up; instead, a warning triangle appears.
I’ve watched the video several times and also downloaded and carefully examined the accompanying source code.
I also noticed today that the link to "Bringing robust navigation structure to your SwiftUI app" has been changed, as the old link no longer works.
The link points to .../swiftui/bringing_robust_navigation_structure_to_your_swiftui_app, but the correct link is .../swiftui/bringing-robust-navigation-structure-to-your-swiftui-app.
Underscores were replaced with hyphens.
I might just stick with the two-column solution.
Christian
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
- Replies
- Boosts
- Views
- Activity
As is often the case, a boolean field helps.
@State private var flagField1: Bool = false
.task(id: field1) {
if flagField1 == false {
flagField1 = true
return
}
print("task 1")
}
As previously mentioned, onChange has a parameter called initial. That is handled better there.
Christian
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
- Replies
- Boosts
- Views
- Activity
The bug report number is FB25051093
Christian
Topic:
Media Technologies
SubTopic:
Audio
Tags:
- Replies
- Boosts
- Views
- Activity
Hi,
thanks for the tip about the bug report. I thought the forum was also for reporting bugs.
The Bug Report number is FB25050954
Christian
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
- Replies
- Boosts
- Views
- Activity
This works
var dataMultiLine: [LocationData.Series] {
LocationData.last30Days
}
struct MultiLineView: View {
var body: some View {
VStack {
Chart {
ForEach(dataMultiLine) { series in
ForEach(series.sales, id: \.day) { element in
LineMark(
x: .value("Day", element.day, unit: .day),
y: .value("Sales", element.sales)
)
}
.foregroundStyle(by: .value("City", series.city))
.symbol(by: .value("City", series.city))
.interpolationMethod(.catmullRom)
}
}
}
.padding()
}
}
This doesn't work
var dataContent: [MonthlyHoursOfSunshine] = [
MonthlyHoursOfSunshine(city: "Cupertino", month: 1, hoursOfSunshine: 196),
MonthlyHoursOfSunshine(city: "Seattle", month: 1, hoursOfSunshine: 74),
MonthlyHoursOfSunshine(city: "Seattle", month: 12, hoursOfSunshine: 62),
MonthlyHoursOfSunshine(city: "Cupertino", month: 12, hoursOfSunshine: 199),
]
struct ContentView: View {
var body: some View {
VStack {
Chart(dataContent) {
LineMark(
x: .value("Month", $0.date),
y: .value("Hours of Sunshine", $0.hoursOfSunshine)
)
.foregroundStyle(by: .value("City", $0.city))
.symbol(by: .value("City", $0.city))
}
}
.padding()
}
}
Christian
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
- Replies
- Boosts
- Views
- Activity
When will there be a bug fix?
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
- Replies
- Boosts
- Views
- Activity