Ios Swift 2.1 tableView未显示数据-功能无效,名称无效(15)
我正在使用Swift开发iOS应用程序。我需要在按下按钮后显示一个tableView。在某种程度上,我在按下按钮后使用了一个子视图来显示我的表格。因此,在操作中,我刚刚编写了Ios Swift 2.1 tableView未显示数据-功能无效,名称无效(15),ios,iphone,swift,uitableview,swift2,Ios,Iphone,Swift,Uitableview,Swift2,我正在使用Swift开发iOS应用程序。我需要在按下按钮后显示一个tableView。在某种程度上,我在按下按钮后使用了一个子视图来显示我的表格。因此,在操作中,我刚刚编写了self.subview.hidden=false,视图中出现了包含表的视图,但问题是tableView没有显示任何数据!调试后,我发现它没有进入tableView函数,该函数返回numberOfRowsInSection和cellForRowAtIndexPath,我在控制台中收到以下消息: _BSMachError: (
self.subview.hidden=false
,视图中出现了包含表的视图,但问题是tableView没有显示任何数据!调试后,我发现它没有进入tableView函数,该函数返回numberOfRowsInSection
和cellForRowAtIndexPath
,我在控制台中收到以下消息:
_BSMachError: (os/kern) invalid capability
_BSMachError: (os/kern) invalid name (15)
注意,我已将tableView与datasource和delegate连接起来,
在一个动作中显示一张桌子的想法有什么问题吗
以下是函数:
func searchBarSearchButtonClicked(searchBar: UISearchBar){
retrievedResults.removeAll(keepCapacity: false)
DirectorySearchBar.resignFirstResponder()
var searchString = DirectorySearchBar.text
if (searchString != ""){
self.subView.hidden = false
retrievedResults = searchForObjects(searchString!)
for res in retrievedResults{
print(res.USER_NAME)
self.SearchResultsTableView.reloadData()
}
}
}
下面是一些不起作用的函数
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if(tableView == self.DirectoryList){
if Selector.selectedSegmentIndex == 0 {
return Students.count
} else {
return Graduates.count
}
} else
{
return retrievedResults.count
}
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if(tableView == self.DirectoryList){
let cell = self.DirectoryList.dequeueReusableCellWithIdentifier("DirectoryCell", forIndexPath: indexPath)
if Selector.selectedSegmentIndex == 0 {
cell.textLabel?.text = Students[indexPath.row].0
} else {
cell.textLabel?.text = Graduates[indexPath.row].0
}
return cell
}
else {
let cell = self.SearchResultsTableView.dequeueReusableCellWithIdentifier("searchCell", forIndexPath: indexPath)
print(retrievedResults[indexPath.row].FULL_NAME)
cell.textLabel?.text = retrievedResults[indexPath.row].FULL_NAME
return cell
}
}
你能添加你的代码吗?@lukeslvi现在添加代码添加你的
numberofrowsension
+cellforrowatinexpath
以及包含数据的数组@Nada@lukeslvi添加,请注意,第一个案例DirectoryList正在加载视图并显示数据的位置工作。。问题是当我显示另一个表视图SearchResultsTableView时,您是否可以显示分配数据源的代码以及SearchResultsTableView
的委托?