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
642
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
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
410
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)   }
2
0
3.0k
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
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
509
Jul ’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 image detail view just show one image from listview?
I have list image and when I click the image list items it show me image details, but it show same image even I click the different image? any idea? Datas:  struct Datas: Identifiable {   var id = UUID().uuidString   var name: String   var detail: String   var image: String } var datas = [   Datas(name: "People1.jpg"),   Datas(name: "People.2jpg"),   Datas(name: "People3.jpg"), ] RowView: struct RowView: View {   var docs: Datas   var body: some View {  NavigationLink(destination:  ListDetailsView(docs: datas[0])) {       Image(docs.image)         .resizable()         .frame(width: 64, height: 48)         } } ListDetailsView: struct ListDetailsView: View {    var docs: Datas       var body: some View {           ZStack{       Image(docs.image)     }         } } struct ListDetailsView_Previews: PreviewProvider {   static var previews: some View {     ListDetailsView(docs: datas[0])   } }
1
0
370
Aug ’21
How can I hide bottom navigation bar when I click the list item?
I have bottom navigation bar and in fist view I have list item, when I click the list item, it is open detail view, but bottom navigation bar still stay in detail view, I want to hide navigation bar when I click open the detail view. Is it possible? ContentView: struct TabView : View {   @State private var selection = 0   @State var index = 0       var body: some View{           VStack(spacing: 0){               ZStack{                 ListView()                     .opacity(self.index == 0 ? 1 : 0)         }               HStack{                   Button(action: {                       self.index = 0                     }) {                       HStack(spacing: 6){                         Image("List")                              .foregroundColor(self.index == 0 ? Color("blue") : .black)                           if self.index == 0{                               Text("List")                 .foregroundColor(Color("blue"))             }                         }           .padding(.vertical,10)           .padding(.horizontal)           .background(self.index == 0 ? Color("tabbar-background") : Color.clear)           .clipShape(Capsule())         }                   Spacer(minLength: 0)                   Button(action: {                       self.index = 1                     }) {                       HStack(spacing: 6){                         Image("SecondList")                              .foregroundColor(self.index == 1 ? Color("blue") : .black)                           if self.index == 1{                               Text("SecondList")                 .foregroundColor(Color("blue"))             }                         }           .padding(.vertical,10)           .padding(.horizontal)           .background(self.index == 1 ? Color("tabbar-background"): Color.clear)           .clipShape(Capsule())         }}}     .edgesIgnoringSafeArea(.bottom)   } } ListView: struct ListView: View {   var body: some View {     VStack{       ScrollView(.vertical, showsIndicators: false, content: {         VStack(spacing: 15){             RowView(docs: docs)                       }         }         }   }     } } struct RowView: View {   @State var docs: Datas   var body: some View {          HStack(spacing: 15){       NavigationLink(destination:  ListDetailView(docs: docs)) {       HStack{       Image(docs.image)         .resizable()         .frame(width: 64, height: 48)                }       }     }     .padding(.horizontal)         } } ListDetailView: import SwiftUI struct ListDetailView: View {   @State var docs: Datas       var body: some View {                 ZStack{       Image(docs.image)         .resizable()         .aspectRatio(contentMode: .fit)             }              } } struct ListDetailView_Previews: PreviewProvider {   static var previews: some View {     ListDetailView(docs: datas[0])           } }
0
0
998
Aug ’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
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
572
Sep ’21