Post

Replies

Boosts

Views

Activity

Thread 1: Fatal error: No ObservableObject of type msgDatas found. A View.environmentObject(_:) for msgDatas may be missing as an ancestor of this view.
It throw fatal error for data in "  self.data.selectedData = i", even I try to calling @State for solve, but nothing change. Main: struct Main : View {       @EnvironmentObject var data : msgDatas   @State var show: Bool = false       var body : some View{           List(msgs){i in               cellView(pic: i.pic, name: i.name, msg: i.msg, time: i.time, msgs: i.msgs).onTapGesture {                   self.data.selectedData = i         self.show.toggle()       }     }   } } cellView: struct cellView : View {       var pic : String   var name : String   var msg : String   var time : String   var msgs : String       var body : some View{           HStack(spacing: 15){               Image(pic).resizable().frame(width: 50, height: 50).clipShape(Circle())               VStack(alignment:.leading,spacing: 5){                   Text(name)         Text(msg).lineLimit(2)       }               Spacer()               VStack(spacing: 10){                   Text(time)         if msgs != ""{                       Text(msgs).padding(8).background(Color("bg")).foregroundColor(.white).clipShape(Circle())         }         else{                       Spacer()         }       }             }.padding(9)   } }
30
0
3.6k
Mar ’21
Trailing closure passed to parameter of type 'Int' that does not accept a closure
I have TabView in ContentView and I want to add TabView for OnboardingView in OtherView, every things work, but it is throw error for TabView in OtherView like "Trailing closure passed to parameter of type 'Int' that does not accept a closure" I do not know why? Any idea? ContentView: struct TabView : View {       var body: some View{           VStack(spacing: 0){ ....... } OtherView:    VStack {     TabView {       ForEach(onboardingData) { onboardingItem in          OnboardingCard(onboardingItem: onboardingItem)       }   }   .tabViewStyle(PageTabViewStyle(indexDisplayMode: .automatic))   .indexViewStyle(PageIndexViewStyle (backgroundDisplayMode:   .always))   .foregroundColor(.white) }
9
1
6.8k
Jan ’26
when click list item, open new SwiftUI for every list items in SwiftUI
I have a simple SwiftUI project, when I click the any list items, I want to route different SwiftUI. Below, I used arrays, and for every SwiftUI, I want to use [0], [1],..., but it throw error, I do not know why? Any idea? ContentView: import SwiftUI struct ContentView: View {   var body: some View {     NavigationView {       List(contacts) { contact in         NavigationLink(destination: NumberOneView(contact: contact)) {           ContactRow(contact: contact)         }       }       .navigationBarTitle("Contacts")     }     .environment(\.colorScheme, .light)   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } } struct ContactRow: View {       let contact: Settings       var body: some View {     HStack {       Image(contact.imageName)         .resizable()         .aspectRatio(contentMode: .fill)         .frame(width: 20, height: 20)                          VStack(alignment: .leading) {         Text(contact.name)           .font(.system(size: 21, weight: .medium, design: .default))                }     }   } } Settings.swift: import Foundation import SwiftUI struct Settings: Identifiable { let imageName: String let name: String let id = UUID() } let contacts = [ Settings(imageName: "image1", name: "NumberOne"), Settings(imageName: "image2", name: "NumberTwo"), Settings(imageName: "image3", name: "NumberThree"), Settings(imageName: "image4", name: "NumberFour"), ] NumberOneView: import SwiftUI struct NumberOneView: View { let contact: Settings var body: some View { Text("hey") } } struct NumberOneView_Previews: PreviewProvider { static var previews: some View { NumberOneView(contact: contacts[0]) } } NumberTwoView: import SwiftUI struct NumberTwoView: View { let contact: Settings var body: some View { Text("hey") } } struct NumberTwoView_Previews: PreviewProvider { static var previews: some View { NumberTwoView(contact: contacts[1]) } }
6
0
4.2k
Mar ’21
How can I handle NavigationLink for HStack row
I want to use NavigationLink for open the chat detail view when I click the rows items. Here example of code I mentioned. Any idea will be appreciated. RecentRowView: import SwiftUI struct RecentRowView: View { var recent: Profile var animation: Namespace.ID // Environment Object... @EnvironmentObject var profileData: ProfileDetailModel var body: some View { HStack(spacing: 15){ // Making it as clickable Button.... Button(action: { withAnimation{ profileData.selectedProfile = recent profileData.showProfile.toggle() } }, label: { ZStack{ // Without matched geometry effect simply showing image... Image(recent.profile) .resizable() .aspectRatio(contentMode: .fill) .frame(width: 60, height: 60) .clipShape(Circle()) if !profileData.showProfile{ Image(recent.profile) .resizable() .aspectRatio(contentMode: .fill) // Matched Geometry Effect... // Giving unique ID that is from UUID from profile Model.... .matchedGeometryEffect(id: recent.id, in: animation) .frame(width: 60, height: 60) .clipShape(Circle()) } } }) // it decreased the highlight color.... .buttonStyle(PlainButtonStyle()) VStack{   NavigationLink(destination: ChatDetailView(), isActive: $profileData.show) { HStack{ VStack(alignment: .leading, spacing: 8, content: { Text(recent.userName) .fontWeight(.bold) Text(recent.lastMsg) .font(.caption) .foregroundColor(.gray) }) Spacer(minLength: 10) Text(recent.time) .font(.caption2) .foregroundColor(.gray) } Divider() } } } .padding(.horizontal) } } struct RecentRowView_Previews: PreviewProvider { static var previews: some View { ContentView() } } ContentView: struct ContentView: View { // ANimation Namespace... @Namespace var animation // StateObject... @StateObject var profileData = ProfileDetailModel() var body: some View { Home(animation: animation) // setting Environment Object... .environmentObject(profileData) } } struct ContentView_Previews: PreviewProvider { static var previews: some View {     NavigationView{ ContentView() } } } ChatDetailView: import SwiftUI struct ChatDetailView: View {   var body: some View {     Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)   } } struct ChatDetailView_Previews: PreviewProvider {   static var previews: some View {     ChatDetailView()   } }
6
0
2.2k
Jun ’21
Why list menu items not shown in SwiftUI project?
I have list item menu project in SwiftUI, my project work, but I have list icons, they are not shown in list view, even I was try to use system image, there is not any change on screen, any idea? struct MasterView: View { let view1 = Menu(name:"Home", image:"image_home", destination:.home) let view2 = Menu(name:"View 1", image:"image_view1", destination:.view1) let view3 = Menu(name:"View 3", image:"image_view2", destination:.view2) var body: some View { let menus: [Menu] = [view1, view2, view3] return List { ForEach(menus) { menu in self.destinationView(menu: menu) }}} func destinationView(menu: Menu) - some View { switch menu.destination { case .view1: return NavigationLink( destination: AnyView(View1(menu: menu)) ) { Text("\(menu.name)") } case .view2: return NavigationLink( destination: AnyView(View2(menu: menu)) ) { Text("\(menu.name)") } default: return NavigationLink( destination: AnyView(HomeView(menu: menu)) ) { Text("\(menu.name)") }}}} Model.swift: /// Main menu item for the list struct Menu: Identifiable { var id = UUID() var name: String var image: String var destination: ViewType } enum ViewType { case home case view1 case view2 }
5
0
1.7k
Apr ’21
Value of type 'Text' has no member 'searchable'
I want to use searchbar for name, but it is throw an arror like " Value of type 'Text' has no member 'searchable'" any idea?   @State private var searchText = ""    Text(data.name)                 .font(.custom("Helvetica Neue", size: 14))                 .searchable(text: $searchText)
4
0
2.9k
Aug ’21
why HStack items not alignnment in SwiftUI?
I have simple project in swiftUI, everythings is work, but HStack for  Rectangle() as I mention below, do not alignment the Rectangle and text at the same line, and idea will be appreciated. struct App: View {   var body: some View {         GeometryReader{g in              ZStack {         ForEach(0..data.count) { i in           DrawShape(center: CGPoint(x:g.frame(in: .global).width/2, y: g.frame(in: .global).height/2), index: i)         }              }     }     .frame(height: 200)          .clipShape(Circle())     .shadow(radius: 10)         VStack{       ForEach(data) { i in         HStack {                     Text(i.name)             .frame(width:100)             .padding()                      GeometryReader { g in             HStack{               Spacer(minLength: 0)               Rectangle()                 .fill(i.color)                 .frame(width: self.getWidth(width: g.frame(in: .global).width, value: i.percent) ,height: 10)                                              Text(String(format: "\(i.percent)", "%.0f"))                 .fontWeight(.bold)                 .padding(.leading,10)                 .frame(width:80)                Spacer()                                            }.frame(width: 240, height: 30)                                      }                     }                 }       .padding()       Spacer()     }                       }   func getWidth(width: CGFloat, value: CGFloat) - CGFloat {     let temp = value / 100     return temp * width   } }
3
0
3.4k
May ’21
How we can use userInteractionEnabled in (number.name) for number only?
I have number.name array like 1.go, 2.java, 3.swift etc..and I do not want to edit the number again, user will only change name. Is it possible?   if words.count == 24 {         for (index, textField) in textFields.enumerated() {           textField.delegate = self           textField.firstDesign()           textField.text = "\(index + 1). \(words[index])"           mneArr.append(words[index])         }
3
0
514
Jul ’21
How can I use the searchable feature for my row data in SwiftUI?
I have data in row like  Text(data.user) and I want to use searchable for it, I can use search bar, bat I want to use filter for user.    Text(data.user)                   .searchable(text: $searchText, placement: .navigationBarDrawer) like here, tere is some example for filter, but how can I use it for my data. Any idea? .onChange(of: searchText) { searchText in       if !searchText.isEmpty {         articles = sampleArticles.filter { $0.title.contains(searchText) }     } else {         articles = sampleArticles     } }
3
0
580
Sep ’21
Why list items not able to delete in SwiftUI?
I have a simple app in SwiftUI, and I try to delete list items in app , project is working, but still list items not able to delete, I do not know what I did not put in my codes, any idea will be appreciated. struct MyView: View { @State private var selectedUsers: MyModel? var body: some View { ScrollView(.vertical, showsIndicators: false, content: { VStack(content: { ForEach(datas){ data in MyRowView(data: data) .contextMenu { Button(action: { self.delete(item: data) }) { Text("delete") } } .onTapGesture { selectedUsers = data } } .onDelete { (indexSet) in selectedUsers.remove(atOffsets: indexSet) }}) })} private func delete(item data: MyModel) { if let index = datas.firstIndex(where: { $0.id == data.id }) { datas.remove(at: index) } }} model: struct MyModel: Identifiable, Hashable, Codable { var id = UUID().uuidString var name: String } var datas = [ MyModel(name: "david"), MyModel(name: "marry"), ]
3
0
2.1k
Feb ’22
How can I use multiple `.alert` dialog in SwiftUI?
I have multiple alert dialog in project, just one of them is work, but I am still do not know why I am not use second one, so how we can use multiple .alert dialog in SwiftUI? struct MyView: View { @State private var selectedUsers: MyModel?   @State var datas: [MyModel]    @State private var deleteRow = false   @State private var deleteRows = false var body: some View { ScrollView(.vertical, showsIndicators: false, content: { VStack(content: { ForEach(datas){ data in MyRowView(data: data) .contextMenu { Button(action: {     deleteRow = true }) { Text("delete") } Button(action: {    deleteRows = true }) { Text("delete") } } .onTapGesture { selectedUsers = data }   .alert(isPresented: $deleteRow) {               Alert(title: Text("title"),                 message: Text("message"),                 primaryButton: .destructive(Text("Delete")) {                                 self.delete(item: data)                                   },                 secondaryButton: .cancel())             }   .alert(isPresented: $deleteRows) {               Alert(title: Text("title"),                 message: Text("message"),                 primaryButton: .destructive(Text("Delete")) {                    self.datas.removeAll()                 },                 secondaryButton: .cancel())             }                               } .onDelete { (indexSet) in self.datas.remove(atOffsets: indexSet) }}) })} private func delete(item data: MyModel) { if let index = datas.firstIndex(where: { $0.id == data.id }) { datas.remove(at: index) } }}
3
1
2.2k
Mar ’22
Thread 1: Fatal error: No ObservableObject of type msgDatas found. A View.environmentObject(_:) for msgDatas may be missing as an ancestor of this view.
I have simple app, when I run my project it work, but then throw error after running like "Thread 1: Fatal error: No ObservableObject of type msgDatas found. A View.environmentObject(_:) for msgDatas may be missing as an ancestor of this view." struct Home: View {   @EnvironmentObject var data : msgDatas       var body : some View{           ZStack{               Color("bg").edgesIgnoringSafeArea(.top)               NavigationLink(destination: Message(), isActive: $data.show) {                 Text("")       }       VStack{                   topView()       }     }   } }
2
0
1.9k
Mar ’21
Value of type 'UISearchBar' has no member 'showLoading'
I have searchBarTextDidEndEditing func , but when I want to call searchBar in other func like that `search.searchBar.showLoading()` it throw error like that "Value of type 'UISearchBar' has no member 'showLoading'" searchBarTextDidEndEditing func: `   func searchBarTextDidEndEditing(_ searchBar: UISearchBar) {     self.search.animationController(forDismissed: self)     self.search.automaticallyShowsSearchResultsController = false   }`
2
0
644
Jun ’21
Thread 1: Fatal error: No ObservableObject of type msgDatas found. A View.environmentObject(_:) for msgDatas may be missing as an ancestor of this view.
It throw fatal error for data in "  self.data.selectedData = i", even I try to calling @State for solve, but nothing change. Main: struct Main : View {       @EnvironmentObject var data : msgDatas   @State var show: Bool = false       var body : some View{           List(msgs){i in               cellView(pic: i.pic, name: i.name, msg: i.msg, time: i.time, msgs: i.msgs).onTapGesture {                   self.data.selectedData = i         self.show.toggle()       }     }   } } cellView: struct cellView : View {       var pic : String   var name : String   var msg : String   var time : String   var msgs : String       var body : some View{           HStack(spacing: 15){               Image(pic).resizable().frame(width: 50, height: 50).clipShape(Circle())               VStack(alignment:.leading,spacing: 5){                   Text(name)         Text(msg).lineLimit(2)       }               Spacer()               VStack(spacing: 10){                   Text(time)         if msgs != ""{                       Text(msgs).padding(8).background(Color("bg")).foregroundColor(.white).clipShape(Circle())         }         else{                       Spacer()         }       }             }.padding(9)   } }
Replies
30
Boosts
0
Views
3.6k
Activity
Mar ’21
Trailing closure passed to parameter of type 'Int' that does not accept a closure
I have TabView in ContentView and I want to add TabView for OnboardingView in OtherView, every things work, but it is throw error for TabView in OtherView like "Trailing closure passed to parameter of type 'Int' that does not accept a closure" I do not know why? Any idea? ContentView: struct TabView : View {       var body: some View{           VStack(spacing: 0){ ....... } OtherView:    VStack {     TabView {       ForEach(onboardingData) { onboardingItem in          OnboardingCard(onboardingItem: onboardingItem)       }   }   .tabViewStyle(PageTabViewStyle(indexDisplayMode: .automatic))   .indexViewStyle(PageIndexViewStyle (backgroundDisplayMode:   .always))   .foregroundColor(.white) }
Replies
9
Boosts
1
Views
6.8k
Activity
Jan ’26
Cannot convert value of type 'EventsTrigger' to expected argument type 'String?
Code below throw error as cannot convert value of type 'EventsTrigger' to expected argument type 'String?, where I miss? EventsTrigger class: public class EventsTrigger: NSObject {   static let instance: EventsTrigger = EventsTrigger() } and  self.service = NewService("node4", EventsTrigger.instance, err)
Replies
7
Boosts
0
Views
511
Activity
Jun ’21
when click list item, open new SwiftUI for every list items in SwiftUI
I have a simple SwiftUI project, when I click the any list items, I want to route different SwiftUI. Below, I used arrays, and for every SwiftUI, I want to use [0], [1],..., but it throw error, I do not know why? Any idea? ContentView: import SwiftUI struct ContentView: View {   var body: some View {     NavigationView {       List(contacts) { contact in         NavigationLink(destination: NumberOneView(contact: contact)) {           ContactRow(contact: contact)         }       }       .navigationBarTitle("Contacts")     }     .environment(\.colorScheme, .light)   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } } struct ContactRow: View {       let contact: Settings       var body: some View {     HStack {       Image(contact.imageName)         .resizable()         .aspectRatio(contentMode: .fill)         .frame(width: 20, height: 20)                          VStack(alignment: .leading) {         Text(contact.name)           .font(.system(size: 21, weight: .medium, design: .default))                }     }   } } Settings.swift: import Foundation import SwiftUI struct Settings: Identifiable { let imageName: String let name: String let id = UUID() } let contacts = [ Settings(imageName: "image1", name: "NumberOne"), Settings(imageName: "image2", name: "NumberTwo"), Settings(imageName: "image3", name: "NumberThree"), Settings(imageName: "image4", name: "NumberFour"), ] NumberOneView: import SwiftUI struct NumberOneView: View { let contact: Settings var body: some View { Text("hey") } } struct NumberOneView_Previews: PreviewProvider { static var previews: some View { NumberOneView(contact: contacts[0]) } } NumberTwoView: import SwiftUI struct NumberTwoView: View { let contact: Settings var body: some View { Text("hey") } } struct NumberTwoView_Previews: PreviewProvider { static var previews: some View { NumberTwoView(contact: contacts[1]) } }
Replies
6
Boosts
0
Views
4.2k
Activity
Mar ’21
How can I handle NavigationLink for HStack row
I want to use NavigationLink for open the chat detail view when I click the rows items. Here example of code I mentioned. Any idea will be appreciated. RecentRowView: import SwiftUI struct RecentRowView: View { var recent: Profile var animation: Namespace.ID // Environment Object... @EnvironmentObject var profileData: ProfileDetailModel var body: some View { HStack(spacing: 15){ // Making it as clickable Button.... Button(action: { withAnimation{ profileData.selectedProfile = recent profileData.showProfile.toggle() } }, label: { ZStack{ // Without matched geometry effect simply showing image... Image(recent.profile) .resizable() .aspectRatio(contentMode: .fill) .frame(width: 60, height: 60) .clipShape(Circle()) if !profileData.showProfile{ Image(recent.profile) .resizable() .aspectRatio(contentMode: .fill) // Matched Geometry Effect... // Giving unique ID that is from UUID from profile Model.... .matchedGeometryEffect(id: recent.id, in: animation) .frame(width: 60, height: 60) .clipShape(Circle()) } } }) // it decreased the highlight color.... .buttonStyle(PlainButtonStyle()) VStack{   NavigationLink(destination: ChatDetailView(), isActive: $profileData.show) { HStack{ VStack(alignment: .leading, spacing: 8, content: { Text(recent.userName) .fontWeight(.bold) Text(recent.lastMsg) .font(.caption) .foregroundColor(.gray) }) Spacer(minLength: 10) Text(recent.time) .font(.caption2) .foregroundColor(.gray) } Divider() } } } .padding(.horizontal) } } struct RecentRowView_Previews: PreviewProvider { static var previews: some View { ContentView() } } ContentView: struct ContentView: View { // ANimation Namespace... @Namespace var animation // StateObject... @StateObject var profileData = ProfileDetailModel() var body: some View { Home(animation: animation) // setting Environment Object... .environmentObject(profileData) } } struct ContentView_Previews: PreviewProvider { static var previews: some View {     NavigationView{ ContentView() } } } ChatDetailView: import SwiftUI struct ChatDetailView: View {   var body: some View {     Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)   } } struct ChatDetailView_Previews: PreviewProvider {   static var previews: some View {     ChatDetailView()   } }
Replies
6
Boosts
0
Views
2.2k
Activity
Jun ’21
Why list menu items not shown in SwiftUI project?
I have list item menu project in SwiftUI, my project work, but I have list icons, they are not shown in list view, even I was try to use system image, there is not any change on screen, any idea? struct MasterView: View { let view1 = Menu(name:"Home", image:"image_home", destination:.home) let view2 = Menu(name:"View 1", image:"image_view1", destination:.view1) let view3 = Menu(name:"View 3", image:"image_view2", destination:.view2) var body: some View { let menus: [Menu] = [view1, view2, view3] return List { ForEach(menus) { menu in self.destinationView(menu: menu) }}} func destinationView(menu: Menu) - some View { switch menu.destination { case .view1: return NavigationLink( destination: AnyView(View1(menu: menu)) ) { Text("\(menu.name)") } case .view2: return NavigationLink( destination: AnyView(View2(menu: menu)) ) { Text("\(menu.name)") } default: return NavigationLink( destination: AnyView(HomeView(menu: menu)) ) { Text("\(menu.name)") }}}} Model.swift: /// Main menu item for the list struct Menu: Identifiable { var id = UUID() var name: String var image: String var destination: ViewType } enum ViewType { case home case view1 case view2 }
Replies
5
Boosts
0
Views
1.7k
Activity
Apr ’21
Value of type 'Text' has no member 'searchable'
I want to use searchbar for name, but it is throw an arror like " Value of type 'Text' has no member 'searchable'" any idea?   @State private var searchText = ""    Text(data.name)                 .font(.custom("Helvetica Neue", size: 14))                 .searchable(text: $searchText)
Replies
4
Boosts
0
Views
2.9k
Activity
Aug ’21
why HStack items not alignnment in SwiftUI?
I have simple project in swiftUI, everythings is work, but HStack for  Rectangle() as I mention below, do not alignment the Rectangle and text at the same line, and idea will be appreciated. struct App: View {   var body: some View {         GeometryReader{g in              ZStack {         ForEach(0..data.count) { i in           DrawShape(center: CGPoint(x:g.frame(in: .global).width/2, y: g.frame(in: .global).height/2), index: i)         }              }     }     .frame(height: 200)          .clipShape(Circle())     .shadow(radius: 10)         VStack{       ForEach(data) { i in         HStack {                     Text(i.name)             .frame(width:100)             .padding()                      GeometryReader { g in             HStack{               Spacer(minLength: 0)               Rectangle()                 .fill(i.color)                 .frame(width: self.getWidth(width: g.frame(in: .global).width, value: i.percent) ,height: 10)                                              Text(String(format: "\(i.percent)", "%.0f"))                 .fontWeight(.bold)                 .padding(.leading,10)                 .frame(width:80)                Spacer()                                            }.frame(width: 240, height: 30)                                      }                     }                 }       .padding()       Spacer()     }                       }   func getWidth(width: CGFloat, value: CGFloat) - CGFloat {     let temp = value / 100     return temp * width   } }
Replies
3
Boosts
0
Views
3.4k
Activity
May ’21
How we can use userInteractionEnabled in (number.name) for number only?
I have number.name array like 1.go, 2.java, 3.swift etc..and I do not want to edit the number again, user will only change name. Is it possible?   if words.count == 24 {         for (index, textField) in textFields.enumerated() {           textField.delegate = self           textField.firstDesign()           textField.text = "\(index + 1). \(words[index])"           mneArr.append(words[index])         }
Replies
3
Boosts
0
Views
514
Activity
Jul ’21
How can I use the searchable feature for my row data in SwiftUI?
I have data in row like  Text(data.user) and I want to use searchable for it, I can use search bar, bat I want to use filter for user.    Text(data.user)                   .searchable(text: $searchText, placement: .navigationBarDrawer) like here, tere is some example for filter, but how can I use it for my data. Any idea? .onChange(of: searchText) { searchText in       if !searchText.isEmpty {         articles = sampleArticles.filter { $0.title.contains(searchText) }     } else {         articles = sampleArticles     } }
Replies
3
Boosts
0
Views
580
Activity
Sep ’21
Why list items not able to delete in SwiftUI?
I have a simple app in SwiftUI, and I try to delete list items in app , project is working, but still list items not able to delete, I do not know what I did not put in my codes, any idea will be appreciated. struct MyView: View { @State private var selectedUsers: MyModel? var body: some View { ScrollView(.vertical, showsIndicators: false, content: { VStack(content: { ForEach(datas){ data in MyRowView(data: data) .contextMenu { Button(action: { self.delete(item: data) }) { Text("delete") } } .onTapGesture { selectedUsers = data } } .onDelete { (indexSet) in selectedUsers.remove(atOffsets: indexSet) }}) })} private func delete(item data: MyModel) { if let index = datas.firstIndex(where: { $0.id == data.id }) { datas.remove(at: index) } }} model: struct MyModel: Identifiable, Hashable, Codable { var id = UUID().uuidString var name: String } var datas = [ MyModel(name: "david"), MyModel(name: "marry"), ]
Replies
3
Boosts
0
Views
2.1k
Activity
Feb ’22
How can I use multiple `.alert` dialog in SwiftUI?
I have multiple alert dialog in project, just one of them is work, but I am still do not know why I am not use second one, so how we can use multiple .alert dialog in SwiftUI? struct MyView: View { @State private var selectedUsers: MyModel?   @State var datas: [MyModel]    @State private var deleteRow = false   @State private var deleteRows = false var body: some View { ScrollView(.vertical, showsIndicators: false, content: { VStack(content: { ForEach(datas){ data in MyRowView(data: data) .contextMenu { Button(action: {     deleteRow = true }) { Text("delete") } Button(action: {    deleteRows = true }) { Text("delete") } } .onTapGesture { selectedUsers = data }   .alert(isPresented: $deleteRow) {               Alert(title: Text("title"),                 message: Text("message"),                 primaryButton: .destructive(Text("Delete")) {                                 self.delete(item: data)                                   },                 secondaryButton: .cancel())             }   .alert(isPresented: $deleteRows) {               Alert(title: Text("title"),                 message: Text("message"),                 primaryButton: .destructive(Text("Delete")) {                    self.datas.removeAll()                 },                 secondaryButton: .cancel())             }                               } .onDelete { (indexSet) in self.datas.remove(atOffsets: indexSet) }}) })} private func delete(item data: MyModel) { if let index = datas.firstIndex(where: { $0.id == data.id }) { datas.remove(at: index) } }}
Replies
3
Boosts
1
Views
2.2k
Activity
Mar ’22
Thread 1: Fatal error: No ObservableObject of type msgDatas found. A View.environmentObject(_:) for msgDatas may be missing as an ancestor of this view.
I have simple app, when I run my project it work, but then throw error after running like "Thread 1: Fatal error: No ObservableObject of type msgDatas found. A View.environmentObject(_:) for msgDatas may be missing as an ancestor of this view." struct Home: View {   @EnvironmentObject var data : msgDatas       var body : some View{           ZStack{               Color("bg").edgesIgnoringSafeArea(.top)               NavigationLink(destination: Message(), isActive: $data.show) {                 Text("")       }       VStack{                   topView()       }     }   } }
Replies
2
Boosts
0
Views
1.9k
Activity
Mar ’21
Can we use the SwiftUI for every IOS app version?
Hi every one, if you build a mobile project with SwiftUI, is it possible to use the app for sub version of IOS like iPhone 6s devices ?
Replies
2
Boosts
0
Views
2.3k
Activity
Jun ’21
Value of type 'UISearchBar' has no member 'showLoading'
I have searchBarTextDidEndEditing func , but when I want to call searchBar in other func like that `search.searchBar.showLoading()` it throw error like that "Value of type 'UISearchBar' has no member 'showLoading'" searchBarTextDidEndEditing func: `   func searchBarTextDidEndEditing(_ searchBar: UISearchBar) {     self.search.animationController(forDismissed: self)     self.search.automaticallyShowsSearchResultsController = false   }`
Replies
2
Boosts
0
Views
644
Activity
Jun ’21