Objective c ios7与UIsearchBarController崩溃?
我正在为第七次失败而努力。 在我的应用程序中,我有UITableView和UISearchBar控制器。 在实现UISearchBar控制器时,我的应用程序崩溃 由于以下原因: 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法将标识符为listcell的单元格出列-必须为标识符注册nib或类,或在情节提要中连接原型单元格” 我正在使用自定义UITableViewCell.UISearchBarController委托方法也已实现 有谁能为我提供更好的链接或解决方案吗 以下是我的代码: //----------------------搜索部件的代码------------------Objective c ios7与UIsearchBarController崩溃?,objective-c,ios5,ios6,ios7,xcode5,Objective C,Ios5,Ios6,Ios7,Xcode5,我正在为第七次失败而努力。 在我的应用程序中,我有UITableView和UISearchBar控制器。 在实现UISearchBar控制器时,我的应用程序崩溃 由于以下原因: 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法将标识符为listcell的单元格出列-必须为标识符注册nib或类,或在情节提要中连接原型单元格” 我正在使用自定义UITableViewCell.UISearchBarController委托方法也已实现 有
谢谢您应该在viewDidLoad方法中添加以下行:
[self.searchDisplayController.searchBar注册表类:[ListCell类]forCellReuseIdentifier:@“ListCell”] 你需要在故事板中设置“listcell”标识符。你能帮我解决这个问题吗storyboard@Nilesh,我已经更新了答案。请跟随
-(void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"SELF Contains[cd] %@",searchText];
searchResults = [_detailList filteredArrayUsingPredicate:resultPredicate];
}
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
[self filterContentForSearchText:searchString scope:[[self.searchDisplayController.searchBar scopeButtonTitles]objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]];
return YES;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == self.searchDisplayController.searchResultsTableView)
{
return [searchResults count];
}
else
return _detailList.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"listcell";
//
ListCell *listcell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
listcell.lbl_detail.text = _detailList [indexPath.row];
listcell.lbl_Address.text = _detailList1 [indexPath.row];
listcell.lbl_link.text = _detailList2 [indexPath.row];
listcell.lbl_number.text = _detailList3 [indexPath.row];
return listcell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[(ContainerViewController *)self.parentViewController addDetailViewController];
}