Edit New issue iPad 搜索样式优化, 不隐藏Navigation #20

This commit is contained in:
life
2015-11-06 09:55:57 +08:00
parent 4f889e637e
commit c1b1cda1a4
6 changed files with 174 additions and 73 deletions

View File

@@ -108,7 +108,7 @@ NSString const *key = @"isSelectOnSearchKey";
-(void)setBarStyle
{
if(self.isSelectOnSearch) {
if(self.isSelectOnSearch && !IS_IPAD) {
[self setBarStyleBlack];
}
else {

View File

@@ -846,13 +846,38 @@
return titleLen;
}
//
// ipadsearch bar, navigation
// ipadnavigationController, SWTableViewCell selectCell
// http://stackoverflow.com/a/5860412/4269908
//- (UINavigationController *)navigationController {
// if (IS_IPAD) {
// return nil;
// } else {
// return self.navigationController;
// }
//}
- (UINavigationController *)navigationController {
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
NSString *sourceString = [[NSThread callStackSymbols] objectAtIndex:1];
// Example: 1 UIKit 0x00540c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"];
NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString componentsSeparatedByCharactersInSet:separatorSet]];
[array removeObject:@""];
// Array[3] == class caller
if([array[3] isEqualToString:@"UISearchDisplayController"]) {
return nil;
}
}
return [super navigationController];
}
//
#pragma mark - UISearchDisplayDelegate Methods
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
NSLog(@"[%@ %@]", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
// NSLog(@"[%@ %@]", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
NSString *searchPredicate = [NSString stringWithFormat:@"title contains[cd] '%@' or content contains[cd] '%@'", searchString, searchString];
@@ -868,8 +893,10 @@
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
[self setBarStyleBlack];
self.isSelectOnSearch = YES;
if (!IS_IPAD) {
[self setBarStyleBlack];
self.isSelectOnSearch = YES;
}
}
- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller
@@ -881,9 +908,11 @@
// reload ?
// [self.tableView reloadData];
if (!IS_IPAD) {
[self restoreBarStyle];
[self restoreBarStyle];
self.isSelectOnSearch = NO;
self.isSelectOnSearch = NO;
}
}
#pragma mark - UISearchBarDelegate Methods

View File

@@ -124,7 +124,7 @@
self.title = NSLocalizedString(@"Notebook", nil);
// , , , search bar,
// , , , search bar,
// http://stackoverflow.com/a/20975075/4269908
[self setAutomaticallyAdjustsScrollViewInsets:YES];
[self setExtendedLayoutIncludesOpaqueBars:YES];
@@ -139,7 +139,8 @@
{
[super viewWillAppear:animated];
if(self.isSelectOnSearch) {
// IPAD, isSelectOnSearch
if(self.isSelectOnSearch && !IS_IPAD) {
NSLog(@"self.isSelectOnSearch viewWillAppear");
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
@@ -791,6 +792,32 @@
return titleLen;
}
// ipadsearch bar, navigation
// ipadnavigationController, SWTableViewCell selectCell
// http://stackoverflow.com/a/5860412/4269908
//- (UINavigationController *)navigationController {
// if (IS_IPAD) {
// return nil;
// } else {
// return self.navigationController;
// }
//}
- (UINavigationController *)navigationController {
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
NSString *sourceString = [[NSThread callStackSymbols] objectAtIndex:1];
// Example: 1 UIKit 0x00540c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"];
NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString componentsSeparatedByCharactersInSet:separatorSet]];
[array removeObject:@""];
// Array[3] == class caller
if([array[3] isEqualToString:@"UISearchDisplayController"]) {
return nil;
}
}
return [super navigationController];
}
#pragma mark - UISearchDisplayDelegate Methods
- (void)searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView
@@ -812,26 +839,30 @@
// , uisearchbar
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
[self setBarStyleBlack];
if (!IS_IPAD) {
// cate
if(self.delegate) {
// 1.
[self setBarStyleBlack];
// cate
if(self.delegate) {
// 1.
[UIView animateWithDuration:0.25f animations:^{
CGRect frame = self.view.frame;
frame.origin.y = [UIApplication sharedApplication].statusBarFrame.size.height;
self.view.frame = frame;
}];
NSLog(@"setNavigationBarHidden YES!!!!!!!!!");
[self.navigationController setNavigationBarHidden:YES animated:YES];
[UIView animateWithDuration:0.25f animations:^{
CGRect frame = self.view.frame;
frame.origin.y = [UIApplication sharedApplication].statusBarFrame.size.height;
frame.size.height = [self.delegate getSearchedViewHeight];
self.view.frame = frame;
}];
NSLog(@"setNavigationBarHidden YES!!!!!!!!!");
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
self.isSelectOnSearch = YES;
CGRect frame = self.view.frame;
frame.size.height = [self.delegate getSearchedViewHeight];
self.view.frame = frame;
}
self.isSelectOnSearch = YES;
}
// ,
- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller
@@ -840,30 +871,34 @@
self.searchedResultsController = nil;
//
// [controller.searchResultsTableView reloadData]; // , !!
// [controller.searchResultsTableView reloadData]; // , !!
[self.tableView reloadData];
[self restoreBarStyle];
if (IS_IPAD) {
// cate
if(self.delegate) {
// 2.
[self restoreBarStyle];
[UIView animateWithDuration:0.25f animations:^{
CGRect frame = self.view.frame;
frame.origin.y = 64;
self.view.frame = frame;
} completion:^(BOOL finished) {
if(finished) {
// cate
if(self.delegate) {
// 2.
[UIView animateWithDuration:0.25f animations:^{
CGRect frame = self.view.frame;
frame.size.height = [self.delegate getCancelSearchViewHeight];
frame.origin.y = 64;
self.view.frame = frame;
}
}];
} completion:^(BOOL finished) {
if(finished) {
CGRect frame = self.view.frame;
frame.size.height = [self.delegate getCancelSearchViewHeight];
self.view.frame = frame;
}
}];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
self.isSelectOnSearch = NO;
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
self.isSelectOnSearch = NO;
}
#pragma mark - UISearchBarDelegate Methods

View File

@@ -127,7 +127,8 @@
[self beautifySearchBar];
[self setBarStyle];
if(self.isSelectOnSearch) {
// IPAD, isSelectOnSearch
if(self.isSelectOnSearch && !IS_IPAD) {
NSLog(@"self.isSelectOnSearch viewWillAppear");
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
@@ -671,6 +672,32 @@
return titleLen;
}
// ipadsearch bar, navigation
// ipadnavigationController, SWTableViewCell selectCell
// http://stackoverflow.com/a/5860412/4269908
//- (UINavigationController *)navigationController {
// if (IS_IPAD) {
// return nil;
// } else {
// return self.navigationController;
// }
//}
- (UINavigationController *)navigationController {
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
NSString *sourceString = [[NSThread callStackSymbols] objectAtIndex:1];
// Example: 1 UIKit 0x00540c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"];
NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString componentsSeparatedByCharactersInSet:separatorSet]];
[array removeObject:@""];
// Array[3] == class caller
if([array[3] isEqualToString:@"UISearchDisplayController"]) {
return nil;
}
}
return [super navigationController];
}
#pragma mark - UISearchDisplayDelegate Methods
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
@@ -687,56 +714,64 @@
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
[self setBarStyleBlack];
// cate
if(self.delegate) {
// 1.
if (!IS_IPAD) {
[self setBarStyleBlack];
// cate
if(self.delegate) {
// 1.
[UIView animateWithDuration:0.25f animations:^{
CGRect frame = self.view.frame;
frame.origin.y = [UIApplication sharedApplication].statusBarFrame.size.height;
self.view.frame = frame;
}];
[self.navigationController setNavigationBarHidden:YES animated:YES];
[UIView animateWithDuration:0.25f animations:^{
CGRect frame = self.view.frame;
frame.origin.y = [UIApplication sharedApplication].statusBarFrame.size.height;
frame.size.height = [self.delegate getSearchedViewHeight];
self.view.frame = frame;
}];
}
self.isSelectOnSearch = YES;
[self.navigationController setNavigationBarHidden:YES animated:YES];
CGRect frame = self.view.frame;
frame.size.height = [self.delegate getSearchedViewHeight];
self.view.frame = frame;
}
self.isSelectOnSearch = YES;
}
- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller
{
NSLog(@"[%@ %@]", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
// NSLog(@"[%@ %@]", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
self.searchedResultsController.delegate = nil;
self.searchedResultsController = nil;
[controller.searchResultsTableView reloadData];
[self.tableView reloadData];
[self restoreBarStyle];
if (!IS_IPAD) {
// cate
if(self.delegate) {
// 2.
[self restoreBarStyle];
[UIView animateWithDuration:0.25f animations:^{
CGRect frame = self.view.frame;
frame.origin.y = 64;
self.view.frame = frame;
} completion:^(BOOL finished) {
if(finished) {
// cate
if(self.delegate) {
// 2.
[UIView animateWithDuration:0.25f animations:^{
CGRect frame = self.view.frame;
frame.size.height = [self.delegate getCancelSearchViewHeight];
frame.origin.y = 64;
self.view.frame = frame;
}
}];
} completion:^(BOOL finished) {
if(finished) {
CGRect frame = self.view.frame;
frame.size.height = [self.delegate getCancelSearchViewHeight];
self.view.frame = frame;
}
}];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
self.isSelectOnSearch = NO;
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
self.isSelectOnSearch = NO;
}
#pragma mark - UISearchBarDelegate Methods

View File

@@ -194,7 +194,7 @@
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="sectionIndexColor" red="0.031372550870000002" green="0.011764707040000001" blue="0.0078431377190000002" alpha="1" colorSpace="deviceRGB"/>
<color key="sectionIndexTrackingBackgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
<searchBar key="tableHeaderView" contentMode="redraw" placeholder="Search Note" translucent="NO" id="wUi-Dr-T3x">
<searchBar key="tableHeaderView" contentMode="redraw" text="" placeholder="Search Note" translucent="NO" id="wUi-Dr-T3x">
<rect key="frame" x="0.0" y="64" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textInputTraits key="textInputTraits"/>

View File

@@ -14,6 +14,8 @@
{
[super setActive: visible animated: animated];
// [self.searchContentsController.navigationController setNavigationBarHidden: NO animated: NO];
/*
[self.searchContentsController.navigationController setNavigationBarHidden: NO animated: NO];