uisearchbar - 不能将 UISearchBar 放在 UITableView 标题中吗?

标签 uisearchbar reloaddata uitableview uisearchbardelegate

我正在努力做到这一点:

Consider a table view with Search Bar on its header.Table view gets refreshed whenever string is searched.



我有 2 节课

TableView Controller (UIViewController 子类)

包含 UITableView - 显示其表

header view of the table is loaded from the Header class(UIToolBar subclass)



.

标题 (UITableView 的标题)
-包含 UISearchBar 及其委托(delegate)



UISearchBarDelegates call back a function in TableViewController



那叫
- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation  

导致App崩溃

函数调用栈帧如下
[UITableView reloadSections:withRowAnimation:]  
[TableViewController functionThatCallsReloadSection]  
[Header searchBarSearchButtonClicked:]  

reloadSection 导致应用程序崩溃。任何想法为什么会这样?

Is it because the delegate function is still active on the stack while the the table view header is reloaded??



我没有更改与表格 View 相关的任何内容(行数或节数没有变化)。我要做的只是重新加载表格 View 。

编辑:
我正在尝试在 iPad 中做所有这些事情,它在使用我不想使用的 UISearchDisplayController 时提供了一个弹出窗口。我已经有一个表格 View ,一旦输入文本并点击搜索按钮,我想刷新它,使用搜索代表。
唯一的问题是,一旦我在 UISearchBar 的搜索委托(delegate)中调用 [UITableView reloadSection:](UISearchBar 位于我要重新加载的 UITableView 的标题上),应用程序就会崩溃。

最佳答案

我能够通过使用 tableViewHeader 而不是使用 table view header 委托(delegate)方法加载 table view header 来解决问题,其中我使用了一个初始化为 table view header 的指针。

关于uisearchbar - 不能将 UISearchBar 放在 UITableView 标题中吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9673303/

相关文章:

ios - 使用 UISearchController 修复了 UISearchBar - 不使用 UITableView 的标题 View

Swift iOS 8+ UISearchBar 图标、占位符和文本居中

swift - moveRowAtIndexPath 后重新加载数据

ios - 向下滚动屏幕后,UITableView 不会弹回

ios - 使用 Storyboard的 UItableView 的空网格

iOS 7 searchdisplaycontroller 和 tableview offset 不一致的偏移量

iphone - 首次使用前 UISearchBar 大小不一致?

swift - UITableView cellForRowAtIndexPath 函数在重新加载函数后未更新

ios - 在 ios swift 中延迟在 tableView 上显示数据

iOS - 在没有编辑模式的情况下允许在 `UITableView` 中进行默认行移动