Revision 5e54703e Classes/FolderViewController.m
b/Classes/FolderViewController.m | ||
---|---|---|
484 | 484 |
|
485 | 485 |
#pragma mark - UISearchDisplayDelegate |
486 | 486 |
|
487 |
- (void)updateSearchBarPlaceholder:(NSInteger)selectedScope { |
|
488 |
NSMutableDictionary *threadDict = [[NSThread currentThread] threadDictionary]; |
|
489 |
NSDateFormatter *dateFormatterSearchPlaceholder = [threadDict objectForKey:@"dateFormatterSearchPlaceholder"]; |
|
490 |
if (!dateFormatterSearchPlaceholder) { |
|
491 |
dateFormatterSearchPlaceholder = [[NSDateFormatter alloc] init]; |
|
492 |
[dateFormatterSearchPlaceholder setTimeZone:[NSTimeZone localTimeZone]]; |
|
493 |
[dateFormatterSearchPlaceholder setDateFormat:@"yyyy-MM-dd"]; |
|
494 |
[threadDict setObject:dateFormatterSearchPlaceholder forKey:@"dateFormatterSearchPlaceholder"]; |
|
495 |
[dateFormatterSearchPlaceholder release]; |
|
496 |
} |
|
497 |
|
|
498 |
if (selectedScope == 0) { |
|
499 |
// all |
|
500 |
self.searchBar.placeholder = [NSString stringWithFormat:@"e.g. .pdf or %@", |
|
501 |
[dateFormatterSearchPlaceholder stringFromDate:[NSDate date]]]; |
|
502 |
} else if (selectedScope == 1) { |
|
503 |
// name |
|
504 |
self.searchBar.placeholder = @"e.g.: .pdf"; |
|
505 |
} else if (selectedScope == 2) { |
|
506 |
// date |
|
507 |
self.searchBar.placeholder = [NSString stringWithFormat:@"e.g.: %@", |
|
508 |
[dateFormatterSearchPlaceholder stringFromDate:[NSDate date]]]; |
|
509 |
} else if (selectedScope == 3) { |
|
510 |
// type |
|
511 |
self.searchBar.placeholder = @"e.g.: .pdf or text/plain"; |
|
512 |
} else { |
|
513 |
// default |
|
514 |
self.searchBar.placeholder = @"Search Folder"; |
|
515 |
} |
|
516 |
} |
|
517 |
|
|
487 | 518 |
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString { |
488 | 519 |
self.searchFilter = searchString; |
489 | 520 |
[self reloadData]; |
... | ... | |
491 | 522 |
} |
492 | 523 |
|
493 | 524 |
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption { |
525 |
// NSLog(@"searchDisplayController:shouldReloadTableForSearchScope: %@", |
|
526 |
// [controller.searchBar.scopeButtonTitles objectAtIndex:searchOption]); |
|
494 | 527 |
[self reloadData]; |
528 |
[self updateSearchBarPlaceholder:searchOption]; |
|
495 | 529 |
return NO; |
496 | 530 |
} |
497 | 531 |
|
... | ... | |
501 | 535 |
self.searchDisplayController.searchResultsTableView.frame = tableViewFrame; |
502 | 536 |
} |
503 | 537 |
|
538 |
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller { |
|
539 |
[self updateSearchBarPlaceholder:controller.searchBar.selectedScopeButtonIndex]; |
|
540 |
} |
|
541 |
|
|
504 | 542 |
- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller { |
505 | 543 |
self.searchFilter = nil; |
506 | 544 |
[self reloadData]; |
545 |
[self updateSearchBarPlaceholder:-1]; |
|
507 | 546 |
} |
508 | 547 |
|
548 |
//#pragma mark - UISearchBarDelegate |
|
549 |
// |
|
550 |
//- (void)searchBar:(UISearchBar *)aSearchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope { |
|
551 |
// NSLog(@"searchBar:selectedScopeButtonIndexDidChange: %@", |
|
552 |
// [aSearchBar.scopeButtonTitles objectAtIndex:selectedScope]); |
|
553 |
//} |
|
554 |
|
|
509 | 555 |
#pragma mark - Button Handlers |
510 | 556 |
|
511 | 557 |
- (IBAction)homeButtonPressed:(id)sender { |
Also available in: Unified diff