Post

Replies

Boosts

Views

Activity

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
633
Jun ’21
why it says "this class is not key value coding-compliant for the key forgotPassword.'?"
I want to use segue when I click the forget password icon , Iit may open "ForgotPasswordEmailCheckController" view, my code is running but it throw error like "Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<MyApp.LoginViewController 0x7fa962b13730> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key forgotPassword.'" I don't know why? ForgotPasswordEmailCheckController: class ForgotPasswordEmailCheckController: UIViewController, UITextFieldDelegate {   var storyboardId: String {     return (value(forKey: "ForgotPasswordEmailCheckController") as? String)!   } LoginViewController:     @IBAction func forgotPassword(_ sender: Any) {           let mainStoryboard = UIStoryboard(name: "Main", bundle: Bundle.main)           guard let forgotPasswordEmailCheckCotroller = mainStoryboard.instantiateViewController(identifier: "ForgotPasswordEmailCheckController") as?     ForgotPasswordEmailCheckController else {       print("Not correct password")       return     }           navigationController?.pushViewController(forgotPasswordEmailCheckCotroller, animated: true)   }
2
0
3.0k
Jul ’21
How To Show A SwiftUI Onboarding Screen Only When To App Launches For The First Time
I want to use onboarding screen in my project, and it is work but I want to use it just once time for app, I do not know how I will do it, is there any way? struct ContentView: View {   @State private var onboardinDone = false   var data = OnboardingData.data       var body: some View {     Group {       if !onboardinDone {         OnboardingView(data: data, doneFunction: {                              print("done onboarding")         })       } else {         MainScreen()       }     }   }        } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } }
2
1
2k
Sep ’23
How we can delete all list items in SwiftUI?
I have a simple app in SwiftUI, and I try to delete all list items with context menu , when I click context menu button, I want to remove all items, is it possible? 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"), ]
2
0
1.7k
Feb ’22
How we can use alert menu before delete list items in SwiftUI?
I have list items in SwiftUI, and when I delete list items I want to delete after alert menu, like "do want to delete your list items, ""yes" or "no" is it possible? 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 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) } }}
2
0
2.5k
Jan ’23
Why it throw ab error as a "Cannot find 'state' in scope" in SwiftUI project?
I have small SwiftUI app, and it throw an error like "Cannot find 'state' in scope" for this line  Register(state: state) I guess it must be like that, but it is throw an error, I do not know what I missed? Any idea? struct Register: View {       @ObservedObject private var viewModel: RegisterViewModel        init(state: AppState) {    self.viewModel =RegisterViewModel(authAPI: AuthService(), state: state)    }       var body: some View { } } struct Register_Previews: PreviewProvider {       @ObservedObject private var viewModel: RegisterViewModel   @State var pushActive = false        init(state: AppState) {    self.viewModel = RegisterViewModel(authAPI: AuthService(), state: state)    }       static var previews: some View {     Register(state: state)   } } class RegisterViewModel: ObservableObject {     @Published var state: AppState       init(authAPI: AuthAPI, state: AppState) {     self.authAPI = authAPI     self.state = state   }     } }
2
0
960
Mar ’22
Why it is throw an error as "Return from initializer without initializing all stored properties" in SwiftUI?
I have simple app in SwiftUI, when I use  @Binding var show : Bool for second register screen, it is throw an error for this line of code   init(state: AppState) {             self.viewModel = RegisterViewModel(authAPI: AuthService(), state: state)           } as a "Return from initializer without initializing all stored properties" any idea? first screen: import SwiftUI struct RegisterFirstScreen: View {   @Binding var show : Bool   init(state: AppState) {             self.viewModel = RegisterViewModel(authAPI: AuthService(), state: state)     }   var body: some View {    NavigationLink(destination: RegisterSecondScreen(state: viewModel.state, show: $show),                            isActive: self.$pushActive) {                 Button {                              viewModel.signUp()                                     } label: {                   Text("Register Now")                     .padding()                    }               } } second screen: struct RegisterSecondScreen: View {   @ObservedObject var state: AppState       @Binding var show : Bool   var body: some View { Text("Next main screen") }}
2
0
2.7k
Mar ’22
Why after pod install throw that error?
I was use pod install for my project and it throw error like below. "[!] The MyApp [Debug] target overrides the FRAMEWORK_SEARCH_PATHS build setting defined in Pods/Target Support Files/Pods-MyApp/Pods-MyApp.debug.xcconfig'. This can lead to problems with the CocoaPods installation   - Use the $(inherited)` flag, or   - Remove the build settings from the target." even I try to fix the xcode with $(inherited) in project target and project, it is still same. I don't know what I miss?
1
0
8.8k
Jun ’21
Cannot convert value of type 'ForgotPasswordEmailCheckController.Type' to expected argument type 'UIViewController'?
I want to use segue programmaticly , but it throw error for ForgotPasswordEmailCheckController as "Cannot convert value of type 'ForgotPasswordEmailCheckController.Type' to expected argument type 'UIViewController'" Any idea? ForgotPasswordEmailCheckController:  class ForgotPasswordEmailCheckController: UIViewController, UITextFieldDelegate {   var storyboardId: String {     return (value(forKey: "ForgotPasswordEmailCheck") as? String)!   } LoginViewController:     @IBAction func forgotPassword(_ sender: Any) {           let mainStoryboard = UIStoryboard(name: "Main", bundle: Bundle.main)           guard let forgotPasswordEmailCheck = mainStoryboard.instantiateViewController(identifier: "ForgotPasswordEmailCheck") as?     ForgotPasswordEmailCheckController else {       print("Not correct password")       return     }           navigationController?.pushViewController(ForgotPasswordEmailCheckController, animated: true)   }
1
0
1.3k
Jul ’21
SwiftUI: Change List row Highlight colour when tapped
The default colour of a list row when tapped is grey. I try many solution on stackoverflow and apple form, I did not solve problem, any idea? RecentRowView: struct RecentRowView: View {         var body: some View {            HStack(spacing: 15){       List{         NavigationLink(destination: SecondView()                           ){                 VStack{         HStack{             VStack(alignment: .leading, spacing: 8, content: {                             Text(recent.name)                 .font(.custom("Helvetica Neue", size: 14))                               })           Spacer(minLength: 10)           ZStack {                 }           }  }          }         }        }     }    }
1
0
4.0k
Sep ’21
Why I am not able to click button and back to ViewController?
I am use SecondView as programmatically, I am click the button in ViewController and open SecondView controller, but I want to back to ViewController. I do not have storyboard in SecondView and I want to click the closeButton and back to ViewController. My code work but when I click the close button it is not work. Any idea? import UIKit class SecondView: UIViewController {       var closeButton = UIButton()   override func viewDidLoad() {     super.viewDidLoad()           closeButton.addTarget(self, action: #selector(dismissActionSheet), for: .touchUpInside)   }       @objc func dismissActionSheet() {     self.navigationController?.popViewController(animated: true)    } }
1
0
399
Jul ’21