내 프로젝트 용 검색 막대를 구현 중입니다. 검색 부분은 괜찮습니다. 원시 데이터를 표시하고 검색 텍스트로 데이터를 필터링 할 수 있습니다. 검색 결과 tableView의 셀을 탭하면 상세 뷰로 전환되지 않았습니다. 그러나 원시 데이터의 경우 세부 뷰로 전환 할 수 있습니다. 스토리 보드를 사용할 때 prepareForSegue
메서드를 사용합니다. 여기 DetailViewController 용 prepareForSegue가있는 검색 모음
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString: @"Book Detail Segue"]) {
BookDetailsTVC *bookDetailsTVC = segue.destinationViewController; // for the detail view controller
bookDetailsTVC.delegate = self;
if (self.tableView == self.searchDisplayController.searchResultsTableView) { // The if block is not working
NSLog(@"Search Display Controller");
bookDetailsTVC.book = [self.searchResults objectAtIndex: self.searchDisplayController.searchResultsTableView.indexPathForSelectedRow.row];
} else {
NSLog(@"Default Display Controller");
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
bookDetailsTVC.book = [self.objects objectAtIndex: indexPath.row];
}
}
}
내가
didSelectRowAtIndexPath
방법을 사용하려고 할 때, 지금까지의 코드, 난 상세보기로 전환 할 수 있습니다.
Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
Unbalanced calls to begin/end appearance transitions for <BookDetailsTVC: 0x69b5300>.
여기 didSelectRowAtIndexPath에 대한 코드입니다 : : 도움을
- (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath
{
BookDetailsTVC *bookDetailsTVC = [[BookDetailsTVC alloc] init];
if (tableView == self.searchDisplayController.searchResultsTableView) {
bookDetailsTVC.book = [self.searchResults objectAtIndex: self.searchDisplayController.searchResultsTableView.indexPathForSelectedRow.row];
[self performSegueWithIdentifier: @"Book Detail Segue" sender:self];
NSLog(@"Search Display Controller");
} else {
bookDetailsTVC.book = [self.objects objectAtIndex: indexPath.row];
[self performSegueWithIdentifier: @"Book Detail Segue" sender: self];
NSLog(@"Default Display Controller");
}
}
감사하지만 같은 오류 메시지를 받았습니다.
저도 고쳐 주셨습니다. 나는 일주일 정도 동안 내 첫 번째 앱에 대해이 애매한 문제를 해결하려고 노력 해왔다. 공유해 주셔서 감사합니다. –
'self.searchDisplayController.active' 부분이 내 밤을 저장했습니다! 고맙습니다. 나는이 튜토리얼을 따라 가고 있었지만 제대로 작동하지 않았다. http://www.raywenderlich.com/16873/how-to-add-search-into-a-table-view 당신의 솔루션이 내 문제를 해결했다. – scaryguy
감사! 내 경우에는 self.searchDisplayController.searchResultsTableView 대신 self.tableView를 사용하여 문제가 발생했습니다. – Borzh