imr*_*nk1 3 iphone uitableview uisearchbar ios5
我正在使用ios5故事板并且有一个带有uisearchbar的tablview,我正在使用过滤结果.我下面从以下博客文章的提示,我也提出了这个问题 http://code-ninja.org/blog/2012/01/08/ios-quick-tip-filtering-a-uitableview-with-a -search-bar /:
我看到的问题是,当从我的过滤数组中获取项目时,自定义UITableViewCell将返回null.在iOS5中我理解你应该只需要通过dequieReusableCell获取一个单元格而不是显式地初始化一个单元格.但是,当搜索栏中的搜索成功匹配时,单元格将返回null.我不确定如何使用自定义样式手动启动我的单元格.有任何想法吗?这是我的cellForRowAtIndexPath方法的一个片段.
ItemCell*cell =(ItemCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; self.searchBar.tableView.if(cell == nil){NSLog(@"为什么当我从搜索栏中成功匹配时会发生这种情况?"); }
这会导致以下错误:断言失败 - [UISearchResultsTableView _createPreparedCellForGlobalRow:withIndexPath
*终止应用程序由于未捕获的异常"NSInternalInconsistencyException",理由是:"数据源的UITableView必须的tableView返回细胞:的cellForRowAtIndexPath:"
Ste*_*her 16
你在dequeueReusableCellWithIdentifier:错误的桌子上打电话.
您的原型在主表中定义,需要从那里出列.执行搜索时,系统会要求您填写特殊搜索表.该表不包含您的单元格原型,并且它不会在原始表中搜索原型!
你的桌子仍然可用self.tableView.你可以从那里出发,甚至是搜索结果表.
而不是这个:
ItemCell *cell = (ItemCell *)[tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
Run Code Online (Sandbox Code Playgroud)
用这个:
ItemCell *cell = (ItemCell *)[self.tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1295 次 |
| 最近记录: |