2009-10-28 22 views
2

隨着這種幫助的時候:白線和「無結果」開頭鍵入

- (void)viewDidLoad { 
[super viewDidLoad]; 
[self.searchDisplayController setActive:YES]; 
[self.searchDisplayController.searchBar becomeFirstResponder]; 
} 

我想表現的鍵盤當視圖加載搜索。它工作得很好,但它看起來相當醜(爲什麼白線在那裏?):

search table with white lines http://img42.yfrog.com/img42/7503/latest1.png

當我開始寫,並刪除所有它看起來的信件像它從一開始就應該:

search table withour white lines http://img3.yfrog.com/img3/6176/testpn.png

我該如何解決這個問題?

而我還有另一個問題。當我開始鍵入內容時,即使在按下「搜索」按鈕之前,它也會立即顯示「無結果」,我該如何改變這種行爲?

search table with 'nothing found' http://img245.yfrog.com/img245/4366/bildschirmfoto20091014ui.png

+0

我會在漢堡的iPhone技術講座上詢問有關這方面的問題,你可以解釋一下這裏發生的事情。 – Jeena 2009-11-11 16:14:59

回答

1

「沒有結果」的問題仍然是一個問題。我在蘋果支持論壇發現,它不是以這種方式實現的。所以我正在尋找解決方法。你要做的第一件事是:

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString { 
    if([searchString length] < 1) [items removeAllObjects]; 
    if ([items count] < 1) { 
     [controller.searchResultsTableView setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.8]]; 
     [controller.searchResultsTableView setRowHeight:800];  
    } 
    return YES; 
} 

這樣,你得到它看起來灰色和半透明的只是一個大的表格單元格。當你重新加載searchTableView,那麼你想改變這個變化:

- (void)gotDataReload { 
    [self.searchDisplayController.searchResultsTableView reloadData]; 
    [self.searchDisplayController.searchResultsTableView setBackgroundColor:[UIColor whiteColor]]; 
    [self.searchDisplayController.searchResultsTableView setRowHeight:44]; 
} 

希望這有助於下一個誰有這個問題。

1

的第一個問題似乎被某種方式與時間。我得到它的工作:

- (void)viewDidAppear:(BOOL)animated { 
    [super viewDidAppear:animated]; 
    [self performSelector:@selector(toTheSearchbar) withObject:self afterDelay:0]; 
} 

- (void)toTheSearchbar { 
    [self.searchDisplayController setActive:YES]; 
    [self.searchDisplayController.searchBar becomeFirstResponder]; 
} 

即使延遲0工作正常,沒有它,我得到的白線。