我目前正試圖找出搜索欄和搜索顯示控制器在用戶提供輸入後不顯示結果的原因。搜索欄和搜索顯示控制器搜索後不顯示結果
1)我非常有信心,代表和正確配置所有
2)我把一切都建立了這樣我就可以看到NSLog
數據被reutrned
3)控制檯這似乎並沒有產生什麼:
-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
[self.searchDisplayController.searchResultsTableView reloadData];
}
4)數據添加到NSMutableArray
但只顯示空白
其他相關問題,這些單元格底部似乎有空白,爲什麼?此外,除了searchBarCancelButtonClicked
還有一種方法可以檢測搜索視圖/模式何時被解散?我必須改變狀態欄顏色...
任何幫助將大大讚賞。
更多代碼:
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
NSString *authorizedSearch = [searchBar.text stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
NSString *post = [NSString stringWithFormat:@"search=%@",authorizedSearch];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%lu",(unsigned long)[postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"blahblahblah/search.php"]]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSURLConnection *conn = [[NSURLConnection alloc]initWithRequest:request delegate:self];
if(conn) {
NSLog(@"Connection Successful");
}else{
}
return YES;
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData*)data{
NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"DATA: %@", ret);
NSArray *objectArray=[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
[resultsJson addObject:objectArray];
[resultsJson addObject:@"1"];
NSLog(@"results: %@",resultsJson);
NSLog(@"count: %i",[resultsJson count]);
}
發佈一些源代碼? – onnoweb 2015-02-06 02:43:45
你想看到更多的? @onnoweb – 2015-02-06 02:44:26