【发布时间】:2016-02-26 06:47:41
【问题描述】:
我的应用程序运行良好,但突然当我点击UISearchBar 并且当我向下滚动UITableView 时没有输入,然后应用程序崩溃并出现以下错误:Thread1 : EXC_BAD_INSTRUCTION
但是当我点击UISearchBar 并输入一些文本时,然后当我向下滚动UITableView 时,应用程序运行正常,它不会崩溃。
最后,当我点击UISearchBar 并输入一些文本并删除所有这些文本时,当我向下滚动UITableView 时,应用程序运行正常,它不会崩溃。
此函数发生错误:
func tableView(historyTableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = historyTableView.dequeueReusableCellWithIdentifier("cell")! as UITableViewCell;
//self.historyTableView.scrollEnabled = true
if(searchActive){
//...Error occurs over here ==>> Thread1 : EXC_BAD_INSTRUCTION
cell.textLabel?.text = filtered[indexPath.row]
} else {
cell.textLabel?.text = data[indexPath.row]
}
return cell;
}
【问题讨论】:
-
你能显示你的完整堆栈跟踪吗
-
使用异常断点将帮助您找出崩溃的确切位置。
-
当您的过滤数组中的任何错误存在于您在表格视图中滚动的索引时,可能会发生这种情况,请检查过滤数组元素。
标签: ios uitableview swift2 uisearchbar