No, I haven't specified any longPress action. I'm facing this problem on my device, as well as on simulator.
Post
Replies
Boosts
Views
Activity
Xcode Version: 11.5 (11E608c)
I can send you the code of that page, which is as follows:
//
// SearchFriendVC.swift
// iSEN
//
// Created by Rahul Pawar on 14/07/20.
// Copyright © 2020 Schnell Technologies. All rights reserved.
// , UISearchResultsUpdating
import UIKit
import Firebase
import FirebaseUI
class SearchFriendVC: UIViewController, UISearchResultsUpdating {
@IBOutlet weak var tableView: UITableView!
// @IBOutlet weak var searchBar: UISearchBar!
//var usersArray : [SearchDataModel] = [SearchDataModel]()
var userArray = [NSDictionary?]()
var filteredUser = [NSDictionary?]()
let searchController = UISearchController(searchResultsController: nil)
var user: NSDictionary?
var ref = Database.database().reference()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
tableView.delegate = self
tableView.dataSource = self
hideKeyboardWhenTappedAround()
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
definesPresentationContext = true
searchController.searchBar.isTranslucent = true
searchController.searchBar.tintColor = .purple
searchController.searchBar.searchBarStyle = .minimal
searchController.searchBar.searchTextField.textColor = .black
tableView.tableHeaderView = searchController.searchBar
//
//tableView.allowsSelection = true
tableView.register(UINib(nibName: "SearchResultTVC", bundle: nil), forCellReuseIdentifier: "searchResultCell")
// retriveData()
ref.child("All Users").queryOrdered(byChild: "Name").observe(.childAdded) { (snapshot) in
self.userArray.append(snapshot.value as? NSDictionary)
self.tableView.insertRows(at: [IndexPath(row: self.userArray.count-1, section: 0)], with: UITableView.RowAnimation.automatic)
}
}
@IBAction func messageBtnPressed( sender: UIButton) {
let messageVC = self.storyboard?.instantiateViewController(identifier: "HomeVC") as! HomeVC
show(messageVC, sender: self)
}
func updateSearchResults(for searchController: UISearchController) {
filterContent(searchText: self.searchController.searchBar.text!)
}
func filterContent(searchText: String){
self.filteredUser = self.userArray.filter{ user in
let userName = user!["Name"] as? String
let userProfile = user!["Profile Image"] as? String
let userID = user!["UserID"] as? String
return (userName?.lowercased().contains(searchText.lowercased()))!
}
tableView.reloadData()
}
}
extension SearchFriendVC: UITableViewDataSource, UITableViewDelegate{
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView( tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if searchController.isActive && searchController.searchBar.text != ""{
return filteredUser.count
}
return userArray.count
}
func tableView( tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "searchResultCell", for: indexPath) as! SearchResultTVC
if searchController.isActive && searchController.searchBar.text != ""{
user = filteredUser[indexPath.row] as? NSDictionary
}else{
user = userArray[indexPath.row] as? NSDictionary
}
cell.nameLabel.text = user?["Name"] as? String
let profileImage = user?["Profile Image"] as! String
cell.profileImage.sdsetImage(with: URL(string: profileImage), completed: nil)
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
if searchController.isActive && searchController.searchBar.text != ""{
user = filteredUser[indexPath.row] as? NSDictionary
let userId = filteredUser[indexPath.row]
print("###########,\(userId?["UserID"])")
let uid = userId?["UserID"] as! String
UserDefaults.standard.set(uid, forKey: "savedFilteredUserID")
performSegue(withIdentifier: "goToFrirndProfile", sender: self)
}else{
user = userArray[indexPath.row] as? NSDictionary
let userID = userArray[indexPath.row]
print("$$$$$$$$$$$$$$$$$,\(userID?["UserID"])")
}
}
}
I have removed deselect in didSelect.
But still facing same problem 😔
I tried to print on tap, for that also I had to hold the cell.
where can I send full project folder?