2010-06-30 1 views
4

달성하고자하는 것은 위로 이동하여 UINavBar를 덮고 오른쪽에 취소 버튼을 포함하는 UISearchBar입니다. 예상대로UITableView가 UISearchBar로 스크롤되지 않음

searchDC = [[[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self] autorelease]; 

은 어떤 일이 끝나는 것은 jQuery과 그냥 스크롤하지 않습니다, 그러나 모든 다른 기능 : 나는 코드의 다음 줄을 사용할 때까지 모두 잘 간다. 해당 행을 제거하면 내비게이션 막대가 표시되고 검색 막대는 바로 아래에 있으며 취소 버튼도 없습니다.

아이디어가 있으십니까?

검색 창을 그리기위한 코드는 다음과 같습니다

self.navigationItem.title = @"Search"; 
searchBar = [[[UISearchBar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.view.bounds.size.width, 44.0f)] autorelease]; 
searchBar.autocorrectionType = UITextAutocorrectionTypeNo; 
searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone; 
searchBar.keyboardType = UIKeyboardTypeAlphabet; 
searchBar.delegate = self; 
[searchBar becomeFirstResponder]; 

tableView.tableHeaderView = searchBar; 
tableView.tableHeaderView.frame = CGRectMake(0.f, 0.f, 480.f, 44.f); 
searchDC = [[[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self] autorelease]; 
searchDC.searchResultsDataSource = self; 
searchDC.searchResultsDelegate = self; 
searchDC.searchResultsTableView.separatorStyle = UITableViewCellSeparatorStyleNone; 
searchDC.searchResultsTableView.scrollEnabled = YES; 

overlayView.frame = CGRectMake(0, 50, 320, 480); 
[self.view addSubview:overlayView]; 
[self.view bringSubviewToFront:overlayView]; 

답변

1

정보가 충분하지 않음이 대답 할 수 있습니다. UISearchDisplayController를 설정할 위치에 UIViewController 또는 UINavigation Controller 코드 (.h 및 .m 모두)를 표시해야합니다.

편집 :

완전히 잘못 구현하고 있습니다. 애플은 애플의 문서에서이 http://developer.apple.com/iphone/library/samplecode/TableSearch/Introduction/Intro.html

+0

죄송합니다. 원래 게시물을 수정했습니다. –

0

을 구현하는 방법에 대한 좋은 예,

있다

Delegate for the search display controller (delegate), which responds to events such the starting or ending of a search, and the showing or hiding of the search interface.

당신의 UITableViewController

searchDC.delegate = self; 

delegate은 또한 추가 설정 searchDC의 searchBar tableView의 headerView에

[self.tableView setTableHeaderView:searchDC.searchBar];