- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个连接到表格 View 的搜索栏。当搜索栏未处于事件状态时,它的工作原理与我想要的完全一样,但当搜索栏处于事件状态时,单元格选择被禁用。我已经对其进行了调试,当我在搜索处于事件状态时选择一行时,甚至没有调用 didSelectRowAtIndexPath。可能是什么原因造成的?
相关代码如下:
class FabricsViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, UISearchBarDelegate, UISearchControllerDelegate, UISearchDisplayDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
searchController.delegate = self
searchController.searchBar.delegate = self
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
searchController.definesPresentationContext = false
searchController.hidesNavigationBarDuringPresentation = false
myTableView.tableHeaderView = searchController.searchBar
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if searching {
searching = false
searchBar?.resignFirstResponder()
FirebaseClient.sharedInstance.joinFabric(uid: self.appDelegate.uid!, fabricKey: allFabrics[indexPath.row].key)
updateFabricList()
} else {
appDelegate.selectedFabricKey = joinedFabrics[indexPath.row].key
performSegue(withIdentifier: "fabricSelected", sender: self)
}
myTableView.deselectRow(at: indexPath, animated: false)
}
func filterContentForSearchText(searchText: String, scope: String = "All") {
if let allFabrics = allFabrics {
filteredFabrics = allFabrics.filter { fabric in
return (fabric.name.lowercased().contains(searchText.lowercased()))
}
myTableView.reloadData()
myTableView.setContentOffset(CGPoint.zero, animated: false)
}
}
}
extension FabricsViewController: UISearchResultsUpdating {
func updateSearchResults(for: UISearchController) {
filterContentForSearchText(searchText: searchController.searchBar.text!)
}
}
最佳答案
覆盖 func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
关于ios - 搜索栏处于事件状态时无法选择 TableViewCell - iOS Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41307138/
[将数据从一个 TableViewCell 传输到另一个 TableViewCell][1] 我有 CountriesViewController 和 tableView ,其中是不同国家/地区的列表
我的 TableView 里面有 3 个 TableViewCell。 第一个 TableViewCell 有:标签 第二个 TableViewCell 有:TextField 第三个 TableVi
我不确定这是否是一个奇怪的设置,但我有两个自定义 tableView 单元格 - 手机手机 电子邮箱 在 PhoneCell 中,我有两个文本字段,这些文本字段中有一些值。在 EmailCell 中,
所以我有一个 ExpyTableView 类型的 mainTableView ( https://github.com/okhanokbay/ExpyTableView )。一切都很好,我设法实现了它
据我了解,我无法使用 socket 连接将单元格中的按钮连接到我的 TableViewController。 不过,我可以使用操作连接将单元格中的按钮连接到我的 TableView。这是我巨大问题的根
我想在动态 UITableViewCell 中添加一个动态 UICollectionView,当 CollectionView 接收并准备 contentView 时,它会自动更新其高度。有什么好的方
I want different images under different heading //ViewController.swift var categories = ["Good Aft
我有以下表格 View : 当用户点击蓝色的 Pay Cash/Card 按钮时,他们会转到另一个 tableView。 我遇到的问题是;当用户单击按钮时,不会在委托(delegate)方法中捕获 t
我有一个带有自定义单元格的 TableView。单元格中的 subview 之一是 UIButton。当用户单击按钮时,我希望背景发生变化。我得到了所有的工作。但问题是,直到我将受影响的单元格滚动出屏
- (void)viewDidLoad { [super viewDidLoad]; [self.tableView registerNib:[UINib nibWithNibName
我今天花了六个多小时研究并尝试创建动态单元,但没有成功。我也找到了一些很棒的教程。我做错了什么,希望有人能告诉我什么。 我的应用: table 开始是空的。单击添加按钮会显示一个模态 VC,其中有两个
请注意此代码。 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITa
我有一个 tableViewCell,总共包含 8 个图像,分为两个 block (每个 block 4 个图像)。这些图像会异步下载并存储到数组中,然后在 tableViewCell 的 cellF
运行我的弹出窗口时,代码显示在左上角,而不是显示在单击图标的同一位置,是否可以更改某些内容来纠正位置? 最佳答案 这是因为您已将 aView 的 CGRect 设置为 x 和 y 为 0。 如果您以编
我用 CustomTableViewCells 制作了一个应用程序。我在 MainStoryBoard 上设置了一个 UIButton。 我想在点击时更改按钮的图像。当我再次点击时,我希望按钮返回到原
我正在编写一个 iOS 应用程序。用户输入电影搜索关键字,它会从 omdbapi.com 获取数据并在表格 View 中显示电影。问题是该 TableView 单元格未正确显示。 项目网址: proj
我目前有一个表格 View ,其中加载的单元格中有一个 uicollectionview。我目前遇到了表格 View 单元格的两个问题。 1) TableView 中的第一个单元格应该具有紫色背景,但
我有一个 TableView,可以在其中加载自定义单元格。在自定义单元格中,有一个文本字段,当表格 View 填充自身时,该文本字段会加载自定义拨号盘并自行关闭。这个 float 数字键盘在初始化期间
这是我的主屏幕当单击单元格突出显示时,描述将转到下一个 View Controller ,并且单元格会突出显示,当我单击未突出显示的单元格时,因此单元格未突出显示,这意味着只有零索引单元格突出显示,没
我想以编程方式将两个文本字段添加到 tableViewCell 子类(稍后会详细介绍),但很难从 View Controller 访问文本字段。 我的 TableView 子类是: - (id)ini
我是一名优秀的程序员,十分优秀!