Hi !
I am having a very strange problem. I display a list of elements, and I created a view that takes this element as a parameter in order to allow the user to modify it in another view.
my var with a forEach :
@Binding var liste : Liste
my code :
ScrollView {
LazyVGrid(columns: [GridItem(.adaptive(minimum: 100))], spacing: 5) {
ForEach(liste.cartes) { c in
NavigationLink(destination: ModifierUneCarte(carte: c)) {
VStack {
Text(c.devant)
.font(.system(size: 14))
Divider()
Text(c.derriere)
.font(.system(size: 14))
}
}
}
}
}
and my ModifierUneCarte :
struct ModifierUneCarte: View {
[...]
@Binding var carte: Carte
[...]
And I have this error on a lot of lines :
Conflicting arguments to generic parameter 'Content' ('<>' vs. '<>' vs. '<>' vs. '<>')
but it's because of :
NavigationLink(destination: EditMap(map: c)) {
because when I remove it everything works...
Post
Replies
Boosts
Views
Activity
Hello everyone,
I have encountered a very strange issue with my SwiftUI code, and I'm hoping you can help me resolve it. Let me explain in more detail how my code works.
In my main view (ContentView), I have a navigation bar (AppBarView) that can collapse and expand based on the scroll position of the page. I also use a TabView to display different views depending on the user's selection.
The problem arises when the navigation bar is expanded, and I scroll back up the page. My ScrollView behaves erratically, causing a shaking effect with an overlapping of the navigation bar and the ScrollView. To better understand the issue, please watch this video: https://www.youtube.com/shorts/LF0ZfwtiiNI
After conducting several searches, I have identified that the following line is causing the issue:
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
Without this line, everything works fine, but I lose the desired visual effect provided by PageTabViewStyle. This is where I'm stuck because I don't understand why this line of code is causing the bug.
You can find the entire project here if you'd like to take a closer look:
link to the GitHub project : link to the GitHub project
Here is an excerpt of the relevant code:
struct ContentView: View {
// ...
var body: some View {
NavigationView {
ZStack(alignment: .bottomTrailing) {
VStack(spacing: 0) {
AppBarView(show: self.$show, selection: $choice)
TabView(selection: $choice) {
// ...
}
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
}
}
}
// ...
}
}
struct AppBarView: View {
// ...
var body: some View {
VStack(spacing: 25) {
if self.show {
// ...
}
HStack {
Button(action: {
selection = 0
}) {
// ...
}
// ...
}
// ...
}
// ...
}
}
struct AfficherLesListesAReviserView: View {
// ...
var body: some View {
GeometryReader { geometry in
ScrollView {
LazyVGrid(columns: [GridItem(.adaptive(minimum: 110))], spacing: 20) {
ForEach(listes.filter { $0.prochaineRevisionDansMoinsDe(99) != nil && ($0.prochaineRevisionDansMoinsDe(99) ?? 0) <= 0 }.sorted(by: { $0.prochaineRevisionDansMoinsDe(99) ?? 0 > $1.prochaineRevisionDansMoinsDe(99) ?? 0 })) { liste in
}
}
// ...
}
// ...
}
// ...
}
}
I would greatly appreciate it if you could help me find a solution to this issue. Feel free to ask me if you need any further information. Any assistance would be highly appreciated.
Thank you once again!
Hello everyone,
I have encountered a very strange issue with my SwiftUI code, and I'm hoping you can help me resolve it. Let me explain in more detail how my code works.
In my main view (ContentView), I have a navigation bar (AppBarView) that can collapse and expand based on the scroll position of the page. I also use a TabView to display different views depending on the user's selection.
The problem arises when the navigation bar is expanded, and I scroll back up the page. My ScrollView behaves erratically, causing a shaking effect with an overlapping of the navigation bar and the ScrollView. To better understand the issue, please watch this video: https://www.youtube.com/shorts/LF0ZfwtiiNI
After conducting several searches, I have identified that the following line is causing the issue:
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
Without this line, everything works fine, but I lose the desired visual effect provided by PageTabViewStyle. This is where I'm stuck because I don't understand why this line of code is causing the bug.
You can find the entire project here if you'd like to take a closer look:
link to the GitHub project
Here is an excerpt of the relevant code:
struct ContentView: View {
// ...
var body: some View {
NavigationView {
ZStack(alignment: .bottomTrailing) {
VStack(spacing: 0) {
AppBarView(show: self.$show, selection: $choice)
TabView(selection: $choice) {
// ...
}
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
}
}
}
// ...
}
}
struct AppBarView: View {
// ...
var body: some View {
VStack(spacing: 25) {
if self.show {
// ...
}
HStack {
Button(action: {
selection = 0
}) {
// ...
}
// ...
}
// ...
}
// ...
}
}
struct AfficherLesListesAReviserView: View {
// ...
var body: some View {
GeometryReader { geometry in
ScrollView {
LazyVGrid(columns: [GridItem(.adaptive(minimum: 110))], spacing: 20) {
ForEach(listes.filter { $0.prochaineRevisionDansMoinsDe(99) != nil && ($0.prochaineRevisionDansMoinsDe(99) ?? 0) <= 0 }.sorted(by: { $0.prochaineRevisionDansMoinsDe(99) ?? 0 > $1.prochaineRevisionDansMoinsDe(99) ?? 0 })) { liste in
}
}
// ...
}
// ...
}
// ...
}
}
I would greatly appreciate it if you could help me find a solution to this issue. Feel free to ask me if you need any further information. Any assistance would be highly appreciated.
Thank you once again!
Hello everyone,
I encounter a very strange problem. I explain to you.
I have a navbar that can fold and unfold depending on the position of the scroll on the page.
My problem is when the navbar is unfolded and I reassemble my page, my ScrollView, bug completely, you have to see the video to understand. There's like a tremor in an overlay of my navbar and my scrollview.
The video of the bug :
https://youtube.com/shorts/LF0ZfwtiiNI?feature=share
After doing several searches I realized that what caused all this was only:
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
Without this line everything works fine. But there is no longer the PageTabViewStyle effect. Do you know a solution because the problem is very strange... I am totally stuck.
The whole project is here if you want to try:
https://github.com/gwentey/2023-perso-learnIO-swift/
thanks in advance to all !
Hello everybody,
I don't understand something. Since 'init(destination:isActive:label:)' was deprecated in iOS 16.0 I can't get the view to change properly.
Here is the code for my page:
import SwiftUI
struct CreerUneListeView: View {
@Environment(\.managedObjectContext) private var viewContext
@State private var nom = ""
@Environment(\.presentationMode) var presentationMode
@State private var isListeCreee = false
var body: some View {
NavigationStack {
ZStack(alignment: .bottomTrailing) {
VStack(spacing: 0) {
VStack(spacing: 25) {
HStack {
Button(action: {
presentationMode.wrappedValue.dismiss()
}) {
Image(systemName: "chevron.left")
.foregroundColor(.white)
}
Text("LearnIO")
.fontWeight(.bold)
.font(.title)
.foregroundColor(.white)
.padding(.leading, 10)
Spacer()
Button(action: {}) {
Image(systemName: "magnifyingglass")
.resizable()
.frame(width: 18, height: 18)
.foregroundColor(.white)
}
}.frame(height: 80)
}
.padding(.horizontal)
.padding(.top, UIApplication.shared.connectedScenes
.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }
.first { $0.isKeyWindow }?.safeAreaInsets.top)
.background(PaletteColorTools.one)
}
.edgesIgnoringSafeArea(.all)
}
GeometryReader { _ in
VStack {
Spacer()
TextField("Nom de la liste", text: $nom)
.padding()
.background(
RoundedRectangle(cornerRadius: 10)
.stroke(PaletteColorTools.one, lineWidth: 2)
)
.padding()
Spacer()
Button(action: {
let liste = Liste(context: viewContext)
liste.nom = self.nom
self.nom = ""
do {
try viewContext.save()
self.isListeCreee = true
}
catch {
// Handle Error
}
}) {
Text("Créer la liste")
.fontWeight(.bold)
.font(.system(size: 20))
.foregroundColor(.white)
.padding()
.background(
RoundedRectangle(cornerRadius: 10)
.stroke(PaletteColorTools.two, lineWidth: 2)
.background(
RoundedRectangle(cornerRadius: 10)
.fill(PaletteColorTools.one)
)
)
}
Spacer()
}
}
.onTapGesture {
KeyboardTools.hideKeyboard()
}
.navigationBarBackButtonHidden(true)
.navigationDestination(isPresented: $isListeCreee){
ContentView()
}
}
}
}
What the code does is simple, after clicking the create list button, (after the viewContext.save()), I want to redirect the user to ContentView. Finally in the idea it would be another view with parameters but it already does not work with ContentView()...
The problem is that the view overlaps really strangely with the other. While I just want to change my mind... but I really can't.
Thanks in advance
Hello everyone,
I'm writing this topic because I'm new to the world of Swift development. I've always done web, with Angular and now I'm learning SwiftUI and swift.
I am currently developing an application that manages lists and in these lists there are cards. The user can create lists and put cards in them. I save the structure of my maps thanks to Coredata (I created a .cdatamodeld file and I created my entities there). Everything works for the moment but I ask myself questions that stress me a lot. In fact I can not understand how to visualize the data:
how to see the structure as a comic?
How to modify the name of an attribute in the backup?
In fact, what I cannot understand is for the next versions that I will put in place.
Basically we agree that I save for example the name of a list (liste->name) and what if I change the attribute name in the code to (liste->listeName), and what will it break everything?
In fact, I'm so afraid of developing a version that brings new things because I'm afraid of destroying all the user data stored in their phone with CoreData.
How to do ? How to make sure that the data will not be lost? I'm really lost.
Could you guide me, or tell me if I am completely off the mark.
Sorry if this message is naive or silly, but I'm brand new and I can't find any information on this subject.
Thank you in advance for your messages,
Hi everyone,
I'm sorry to bother you, but I'm having a very annoying problem that I can't solve despite a lot of debugging time...
I will explain the context to you very quickly. I have a card list table (listes: [Liste]) in my ContentView page I do a foreach, and I pass one of the lists in binding in another view (AfficherUneListeView), and on this page I have a button which allows to modify the name of the list. When I'm on the edit list page and click on the textfield, my page "crashes" but not the app. So impossible to update the name (unless I'm very fast, I can modify a character and it spits (see the video to believe it).
https://youtu.be/9O-dATdAp2I
Here is the flow diagram of the list variable:
ContentView -> then binding on AfficherUneListeView then Binding on ModifierUneListeVuew then Binding on TextField
I have attached all the files necessary to make it work, the code. I searched for hours, I followed tutorials... I can't understand I'm desperate, thank you in advance everyone!
Model structures (carte, listes, session) :
Carte.swift
Liste.swift
Session.swift
And the app :
ContentView.swift
ModifierUneListeView.swift
AfficherUneListeView.swift