Post

Replies

Boosts

Views

Activity

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
3k
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.8k
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
984
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.8k
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
4k
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
415
Jul ’21
Change icons border when click the bottom tab bar in Swift
I have custom bottom navigation bar in IOS application, everythings work very well, and I want to change bottom navigation items tint color when I click the items, and I was use the self.imgView.image!.withRenderingMode(.alwaysTemplate) self.imgView.tintColor = .red in isSelected, and it is change whole icons border tint color. I do not know where I miss, any idea? RootStackTabViewController: class RootStackTabViewController: UIViewController { @IBOutlet weak var bottomStack: UIStackView! var currentIndex = 0 lazy var tabs: [StackItemView] = { var items = [StackItemView]() for _ in 0..<5 { items.append(StackItemView.newInstance) } return items }() lazy var tabModels: [BottomStackItem] = { return [ BottomStackItem(title: "Home", image: "home"), BottomStackItem(title: "Favorites", image: "heart"), BottomStackItem(title: "Search", image: "search"), BottomStackItem(title: "Profile", image: "user"), BottomStackItem(title: "Settings", image: "settings") ] }() override func viewDidLoad() { super.viewDidLoad() self.setupTabs() } func setupTabs() { for (index, model) in self.tabModels.enumerated() { let tabView = self.tabs[index] model.isSelected = index == 0 tabView.item = model tabView.delegate = self self.bottomStack.addArrangedSubview(tabView) } } } StackItemView: protocol StackItemViewDelegate: AnyObject { func handleTap(_ view: StackItemView) } class StackItemView: UIView { @IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var imgView: UIImageView! @IBOutlet weak var highlightView: UIView! private let higlightBGColor = UIColor(hexString: "1160FB") static var newInstance: StackItemView { return Bundle.main.loadNibNamed( StackItemView.className(), owner: nil, options: nil )?.first as! StackItemView } weak var delegate: StackItemViewDelegate? override func awakeFromNib() { super.awakeFromNib() self.addTapGesture() } var isSelected: Bool = false { willSet { self.updateUI(isSelected: newValue) self.titleLabel.textColor = UIColor.white self.imgView.image!.withRenderingMode(.alwaysTemplate) self.imgView.tintColor = .red } } var item: Any? { didSet { self.configure(self.item) } } private func configure(_ item: Any?) { guard let model = item as? BottomStackItem else { return } self.titleLabel.text = model.title self.imgView.image = UIImage(named: model.image) self.isSelected = model.isSelected } private func updateUI(isSelected: Bool) { guard let model = item as? BottomStackItem else { return } model.isSelected = isSelected let options: UIView.AnimationOptions = isSelected ? [.curveEaseIn] : [.curveEaseOut] UIView.animate(withDuration: 0.4, delay: 0.0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0.5, options: options, animations: { self.titleLabel.text = isSelected ? model.title : "" let color = isSelected ? self.higlightBGColor : .white self.highlightView.backgroundColor = color (self.superview as? UIStackView)?.layoutIfNeeded() }, completion: nil) } } extension StackItemView { func addTapGesture() { let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleGesture(_:))) self.addGestureRecognizer(tapGesture) } @objc func handleGesture(_ sender: UITapGestureRecognizer) { self.delegate?.handleTap(self) } }
1
0
1.2k
Jul ’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)   }
Replies
2
Boosts
0
Views
3k
Activity
Jul ’21
Is it possible to update SwiftUI 2.0 project to Swift 3.0?
I have project in SwiftUI 2.0 and I want to update it for Swift 3.0, is it possible to do that?
Replies
2
Boosts
0
Views
982
Activity
Aug ’21
How can I hide cancel in title in searchbale bar in SwiftUI?
I have searchable properties in my project, everythings work, but it is looking bad when I search any items, it show "cancel" title inside of the search bar, how can I hide it?   .searchable(text: $searchText, placement: .navigationBarDrawer(displayMode: .always))
Replies
2
Boosts
0
Views
2.1k
Activity
Sep ’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()   } }
Replies
2
Boosts
1
Views
2k
Activity
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"), ]
Replies
2
Boosts
0
Views
1.8k
Activity
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) } }}
Replies
2
Boosts
0
Views
2.5k
Activity
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   }     } }
Replies
2
Boosts
0
Views
984
Activity
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") }}
Replies
2
Boosts
0
Views
2.8k
Activity
Mar ’22
Why I get notification always in macbook in top right corner?
When I update my macbook to macOS13 Venture , I have a problem in top right corner, always give alots of notifications , how can I solve it?
Replies
2
Boosts
0
Views
858
Activity
Jan ’23
why still say "No such module 'AssetsPickerViewController'" , even I updated pod file?
I have new project and I added "pod 'AssetsPickerViewController', '~> 2.0' " to pod file and import AssetsPickerViewController to my project file, but still throw this error? Any idea?
Replies
1
Boosts
0
Views
751
Activity
Jun ’21
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?
Replies
1
Boosts
0
Views
8.8k
Activity
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)   }
Replies
1
Boosts
0
Views
1.3k
Activity
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 {                 }           }  }          }         }        }     }    }
Replies
1
Boosts
0
Views
4k
Activity
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)    } }
Replies
1
Boosts
0
Views
415
Activity
Jul ’21
Change icons border when click the bottom tab bar in Swift
I have custom bottom navigation bar in IOS application, everythings work very well, and I want to change bottom navigation items tint color when I click the items, and I was use the self.imgView.image!.withRenderingMode(.alwaysTemplate) self.imgView.tintColor = .red in isSelected, and it is change whole icons border tint color. I do not know where I miss, any idea? RootStackTabViewController: class RootStackTabViewController: UIViewController { @IBOutlet weak var bottomStack: UIStackView! var currentIndex = 0 lazy var tabs: [StackItemView] = { var items = [StackItemView]() for _ in 0..<5 { items.append(StackItemView.newInstance) } return items }() lazy var tabModels: [BottomStackItem] = { return [ BottomStackItem(title: "Home", image: "home"), BottomStackItem(title: "Favorites", image: "heart"), BottomStackItem(title: "Search", image: "search"), BottomStackItem(title: "Profile", image: "user"), BottomStackItem(title: "Settings", image: "settings") ] }() override func viewDidLoad() { super.viewDidLoad() self.setupTabs() } func setupTabs() { for (index, model) in self.tabModels.enumerated() { let tabView = self.tabs[index] model.isSelected = index == 0 tabView.item = model tabView.delegate = self self.bottomStack.addArrangedSubview(tabView) } } } StackItemView: protocol StackItemViewDelegate: AnyObject { func handleTap(_ view: StackItemView) } class StackItemView: UIView { @IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var imgView: UIImageView! @IBOutlet weak var highlightView: UIView! private let higlightBGColor = UIColor(hexString: "1160FB") static var newInstance: StackItemView { return Bundle.main.loadNibNamed( StackItemView.className(), owner: nil, options: nil )?.first as! StackItemView } weak var delegate: StackItemViewDelegate? override func awakeFromNib() { super.awakeFromNib() self.addTapGesture() } var isSelected: Bool = false { willSet { self.updateUI(isSelected: newValue) self.titleLabel.textColor = UIColor.white self.imgView.image!.withRenderingMode(.alwaysTemplate) self.imgView.tintColor = .red } } var item: Any? { didSet { self.configure(self.item) } } private func configure(_ item: Any?) { guard let model = item as? BottomStackItem else { return } self.titleLabel.text = model.title self.imgView.image = UIImage(named: model.image) self.isSelected = model.isSelected } private func updateUI(isSelected: Bool) { guard let model = item as? BottomStackItem else { return } model.isSelected = isSelected let options: UIView.AnimationOptions = isSelected ? [.curveEaseIn] : [.curveEaseOut] UIView.animate(withDuration: 0.4, delay: 0.0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0.5, options: options, animations: { self.titleLabel.text = isSelected ? model.title : "" let color = isSelected ? self.higlightBGColor : .white self.highlightView.backgroundColor = color (self.superview as? UIStackView)?.layoutIfNeeded() }, completion: nil) } } extension StackItemView { func addTapGesture() { let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleGesture(_:))) self.addGestureRecognizer(tapGesture) } @objc func handleGesture(_ sender: UITapGestureRecognizer) { self.delegate?.handleTap(self) } }
Replies
1
Boosts
0
Views
1.2k
Activity
Jul ’21