Found a solution.
Replace the form with ScrollView instead of NavigationView and the picker will work :)
Post
Replies
Boosts
Views
Activity
Here what I've figured out:
If a picker is inside a Form, it's going to be frozen and not selectable
Form {
Picker("Choose a number", selection: $selection) {
ForEach(0 ..< data.count, id: \.self) { index in
Text(data[index])
}
}
}
If I wrap this form in a NavigationView, it's going to work perfectly.
NavigationView {
Form {
Picker("Choose a number", selection: $selection) {
ForEach(0 ..< data.count, id: \.self) { index in
Text(data[index])
}
}
}
However for my current design, I can't have a NavigationView on this View.
Is there a solution for that ?
Thx
I dont want to do differently.
But when I do this way, self.callApi2(id) doesnt wait for self.callApi1 to finish.
self.callApi2(id) is triggered at the same time and because doesnt have an ID yet, it fails.
var id = self.callApi1()
self.callApi2(id)
If I do this way I will have "Argument passed to call that takes no arguments"
I also tried:
store.getHomeItems() { () -> in
This is the signature for the method:
func getHomeItems() {
...
}
You're right. I am doing in init.
But if I remove from init, how can I create the loop to create the navigation links in body?
struct MyListView: View {
var category: categoryModel
@ObservedObject var store = MyStore()
init(category: CategoryModel) {
self.category = category
store.getItemsByCategoryId: category.id)
}
var body: some View {
List(store.categories.indices, id:\.self) { categoryIndex in
let category = store.categories[categoryIndex]
NavigationLink(destination:
CategoryView(categoryId: category.id)
)
{
CategoryRow(category: category)
}
}
}
I tried to do that, but somehow the MyViewB (actually it's a list view) is opened but not active.
What I mean by that is the listview is loaded inside (Sheet/FullScreenCover) but you can't select anything on it.
The problem was cache on my old computer :(
There is no view since it's all done on the info.plist file
The problem is when I am inside my formatDate function, if I debug mousing over the dateString variable, I can see the value "3000-01-01T08:00:00-08:00".
But when it reaches the line "let finalDate = dateFormatter.date(from: dateString)!", it returns me the error "Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value"
The question is how it found nil, if when I mouse over the dateString variable, I can see the value in there ?
func formatDate(dateString: String) -> Date {
//first I dont know why my parameter gets here nil
let dateFormatter = ISO8601DateFormatter()
//at the dateFormatter, doesnt matter the options I set, the return is always the same.
dateFormatter.formatOptions = [
.withFullDate,
.withFullTime,
]
let finalDate = dateFormatter.date(from: dateString)!
return finalDate
}
Nice thx
Nice thx
Fatal error: Unexpectedly found nil while unwrapping an Optional value.
It happens on my View (myStore.product!.title)